I am trying to use a custom EGIS Land Use dataset for WRF-UCM by converting it into a binary (BIL) file. However, after running geogrid.exe, the generated geo_em.d03.nc file does not reflect my custom dataset, and LU_INDEX remains at 17 across the entire domain.
Steps I Followed:
- Converted an EGIS shapefile to raster using Python (rasterio).
- Saved it as a BIL filewith EHdr format (8-bit categorical).
-
Python:
ds["MODIS_CODE"] = ds["MODIS_CODE"].astype(np.uint8) ds = ds.to_crs("EPSG:4326") resolution = 0.00083333 bounds = ds.total_bounds left, bottom, right, top = bounds width = int((right - left) / resolution) height = int((top - bottom) / resolution) raster_array = np.full((height, width), 0, dtype=np.uint8) shapes = [(geom, value) for geom, value in zip(ds.geometry, ds["MODIS_CODE"])] rasterized = rasterize( shapes, out_shape=(height, width), transform=from_origin(left, top, resolution, resolution), fill=0, dtype=np.uint8 ) binary_output = "./EGIS_LANDUSE.2023.v8/EGIS_LANDUSE.bil" with rasterio.open( binary_output, "w", driver="EHdr", width=width, height=height, count=1, dtype=np.uint8, crs="EPSG:4326", transform=from_origin(left, top, resolution, resolution), ) as dst: dst.write(rasterized, 1)
-
- Configured GEOGRID.TBLto reference my dataset (egis_landuse).
-
INI:
name=LANDUSEF priority = 2 dest_type = categorical z_dim_name = land_cat dominant = LU_INDEX landmask_water = egis_landuse:17,21 # Calculate a landmask from this field interp_option = egis_landuse:nearest_neighbor rel_path = egis_landuse:egis_landuse/
-
- Ran geogrid.exe, and the log confirms that my dataset is being processed.
- Checked geo_em.d03.nc, but my land use data is not applied.
Verification Checks & Findings
- Endian Check:
- Used od -An -t d1 00001-01890.00001-01200 | head -n 20
- Values appear correctly stored as uint8 integers.
- Coordinate System Check:
- ncdump -h geo_em.d03.nc | grep -i 'MAP_PROJ' → MAP_PROJ = 1 (Lambert Conformal Projection).
- ncdump -h geo_em.d03.nc | grep -i 'DX\|DY' → DX = 0.00083333, DY = 0.00083333.
- BIL File Header & Data Integrity:
- BIL file size matches expected dimensions.
- hexdump -C shows diverse land use values.
- row_order = top_bottom was confirmed in the metadata.
Problem & Observations:
- geogrid.log confirms that egis_landuse is being processed.
- However, in geo_em.d03.nc, LU_INDEX remains 17 across all points instead of reflecting EGIS data.
- When using geog_res_path = egis_landuse+default, LU_INDEX is set to a single code (not reflecting EGIS values).
- When using geog_res_path = default+egis_landuse, only the default dataset is applied.
Questions:
- Is using rasterio instead of GDAL causing an issue with the BIL file format?
- Does WRF require a specific Endian format for BIL files? How can I ensure my file is formatted correctly?
- Should I reproject my dataset to match WRF’s Lambert Projection instead of using EPSG:4326?
- How can I verify that geogrid.exe is correctly reading my binary file and not defaulting to MODIS?
- Are there specific settings in GEOGRID.TBL that must be changed to force egis_landuse to overwrite default land use data?