Skip to content

Commit

Permalink
avoid valuerror with empty coastline list (#717)
Browse files Browse the repository at this point in the history
* avoid valuerror with empty coastline list

* updated whatsnew
  • Loading branch information
veenstrajelmer authored Dec 13, 2023
1 parent 08af61c commit f921fcc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dfm_tools/coastlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ def get_coastlines_gdb(res:str='h', bbox:tuple = (-180, -90, 180, 90), min_area:
coastlines_gdb_L3 = gpd.read_file(file_shp_L3, include_fields=include_fields, where=f"area>{min_area}", bbox=bbox)
coastlines_gdb_list.append(coastlines_gdb_L3)

# remove empty geodataframes from list to avoid FutureWarning and concatenate
# remove empty geodataframes from list to avoid FutureWarning
# escape for empty resulting list and concatenate otherwise
coastlines_gdb_list = [x for x in coastlines_gdb_list if not x.empty]
if not coastlines_gdb_list:
return gpd.GeoDataFrame()
coastlines_gdb = pd.concat(coastlines_gdb_list)
print(f'{(dt.datetime.now()-dtstart).total_seconds():.2f} sec')

Expand Down
3 changes: 3 additions & 0 deletions docs/whats-new.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
- automatically parse epsg from FM mapfile to crs in `dfmt.open_partitioned_dataset()` by [@veenstrajelmer](https://github.com/veenstrajelmer) in [#685](https://github.com/Deltares/dfm_tools/pull/685)
- added spatial/temporal subsetting and retrieving of insitu observation data with `dfmt.ssh_catalog_subset()` and `dfmt.ssh_retrieve_data()` by [@veenstrajelmer](https://github.com/veenstrajelmer) in [#711](https://github.com/Deltares/dfm_tools/pull/711)

### Fix
- prevent ValueError upon concatenation of only emtpy coastlines geodataframes by [@veenstrajelmer](https://github.com/veenstrajelmer) in [#717](https://github.com/Deltares/dfm_tools/pull/717)


## 0.18.0 (2023-12-08)

Expand Down

0 comments on commit f921fcc

Please sign in to comment.