Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add name check for basin id field #8

Merged
merged 2 commits into from
Jun 2, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion code/Caravan_part1_Earth_Engine.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"\n",
"- `OUTPUT_FOLDER_NAME`: The name of the folder (in Google Drive) that is used to store the resulting data. For example, `OUTPUT_FOLDER_NAME = 'my_caravan_extension'` will create a folder called `my_caravan_extension` in the main directory of your Google Drive.\n",
"\n",
"- `BASIN_ID_FIELD`: Name of the attribute field in the shapefile that contains the basin id.\n",
"- `BASIN_ID_FIELD`: Name of the attribute field in the shapefile that contains the basin id. Make sure that this name does not conflict with any of the field names of HydroATLAS. For example, you could use something like `'gauge_id'` or `'basin_id'` but _not_ `'HYBAS_ID'`, `'PFAF_ID'`, or `'MAIN_BAS'`, which are all existing field names in HydroATLAS/HydroSHEDS.\n",
"\n",
"- `BASIN_PREFIX`: A short descriptive string that is prepended to each basin id and that should be unique within the Caravan data space. For example, we use `camels` for basins from the CAMELS (US) dataset and `camelsgb` from the CAMELS-GB dataset. The final name for each basin within the attribute table will be `{BASIN_PREFIX}_{GAUGE_ID}`. Note, if you already included such a prefix in the basin id field of your shapefile, leave this field as an empty string. Please also read the README in the Caravan dataset folder on details about the folder structure of the dataset.\n",
"\n",
Expand Down Expand Up @@ -332,6 +332,13 @@
"# get list list of all available hydroatlas feature properties\n",
"property_names = hydro_atlas.first().propertyNames().getInfo()\n",
"\n",
"# Make sure that BASIN_ID_FIELD is not a field name of HydroATLAS\n",
"if BASIN_ID_FIELD in property_names:\n",
" msg = (f\"BASIN_ID_FIELD {BASIN_ID_FIELD} has the same name as one of the \"\n",
" \"HydroATLAS fields, which is not allowed. Please rename the basin \"\n",
" \"id field in your shapefile and reingested the shapefile in Earth Engine\")\n",
kratzert marked this conversation as resolved.
Show resolved Hide resolved
" raise ValueError(\"\".join(msg))\n",
"\n",
"print(f\"Found {len(property_names)} features initially\")\n",
"\n",
"# List of features for which we take the area-weighted majority vote\n",
Expand Down