WRFHYDRO GIS Preprocessing error

17 views
Skip to first unread message

ved prakash

unread,
Jun 11, 2024, 7:45:40 AMJun 11
to wrf-hydro_users
The WRFHYDRO GIS Preprocessing is unable to execute for lakeid. The error I get when I am executing :-  [ ! python Build_Routing_Stack.py -i {in_geogrid} -l {lakes} --CSV {csv} -d {in_dem} -R {regrid_factor} -t {routing_cells} -o {out_zip} ] is as follow :- 

Using provided lake ID field: ID
Starting to gather lake centroid and area information.
feature: <osgeo.ogr.Feature; proxy of <Swig Object of type 'OGRFeatureShadow *' at 0x7181af535a10> >
Traceback (most recent call last):
  File "/home/wrf_hydro_fnl/WRFHYDRO_Preprocessing/wrf_hydro_gis_preprocessor/wrfhydro_gis/Build_Routing_Stack.py", line 544, in <module>
    GEOGRID_STANDALONE(args.in_Geogrid,
  File "/home/wrf_hydro_fnl/WRFHYDRO_Preprocessing/wrf_hydro_gis_preprocessor/wrfhydro_gis/Build_Routing_Stack.py", line 327, in GEOGRID_STANDALONE
    rootgrp2, lake_ID_field = wrfh.add_reservoirs(rootgrp2,
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wrf_hydro_fnl/WRFHYDRO_Preprocessing/wrf_hydro_gis_preprocessor/wrfhydro_gis/wrfhydro_functions.py", line 3063, in add_reservoirs
    idval = feature.GetField(lakeID)
            ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wrf_hydro_fnl/WRFHYDRO_STANDALONE/miniconda3/envs/qgis_stable.3.28.8/lib/python3.11/site-packages/osgeo/ogr.py", line 4248, in GetField
    raise KeyError("Illegal field requested in GetField()")
KeyError: 'Illegal field requested in GetField()'

Thank you
With regards
Ved


Kevin

unread,
Jun 11, 2024, 11:18:21 AMJun 11
to wrf-hydro_users, ved prakash
Ved,

Some changes have been made recently to the reservoir ID scheme in the WRF-Hydro GIS Pre-processor. It looks like the version you are using is expecting there to be a field "ID" present in your reservoir shapefile, and it is not finding that field. If you wish, you can modify the "wrfh.add_reservoirs" function and change the 'lakeIDfield' keyword to "None". If you do this, the pre-processor will automatically assign a new ID field and new, sequential lake IDs to your routing stack.

Kevin

ved prakash

unread,
Jun 11, 2024, 10:49:30 PMJun 11
to wrf-hydro_users, Kevin, ved prakash
Dear Kevin

Thank you for prompt response. i have tried to change the following line of Build_Routing_Stack.py  as :- 
        # Alter Channelgrid for reservoirs and build reservoir inputs
        print('    Reservoir polygons provided. Lake routing will be activated.')
        rootgrp2, lake_ID_field = wrfh.add_reservoirs(rootgrp2, projdir, fac,
                                                        in_lakes,
                                                        fine_grid,
                                                        Gridded=gridded,
                                                        lakeIDfield='None')

Still i am getting the same error.

Thank you

Kevin Sampson

unread,
Jun 11, 2024, 10:51:27 PMJun 11
to ved prakash, wrf-hydro_users
Do not put “None” in quotes. None is a special argument in Python and should not be put in quotes in this function. Let me know if that works.

Kevin

Kevin Sampson, GISP
Associate Scientist
NSF National Center for Atmospheric Research
Boulder, Colorado

ved prakash

unread,
Jun 11, 2024, 10:54:11 PMJun 11
to ksam...@ucar.edu, wrf-hyd...@ucar.edu

Thank you Kevin, it is working now.

Reply all
Reply to author
Forward
0 new messages