Commit 33f3f4c
fix(nldi): return an empty GeoDataFrame instead of crashing on empty results (#302)
NLDI can legitimately return no features (e.g. a feature with nothing upstream),
and _query_nldi returns {} when a 200 response carries no JSON body (per its own
comment). The getters then called gpd.GeoDataFrame.from_features(..., crs=_CRS),
which raises "Assigning CRS to a GeoDataFrame without a geometry column is not
supported" — an opaque crash on a valid empty result. (as_json=True already
tolerated empties; the default GeoDataFrame path did not.)
Added a shared _features_to_gdf helper, used by all four getters, that returns
an empty GeoDataFrame with the correct CRS when there are no features.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent ee653e5 commit 33f3f4c
1 file changed
Lines changed: 19 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
35 | 50 | | |
36 | 51 | | |
37 | 52 | | |
| |||
104 | 119 | | |
105 | 120 | | |
106 | 121 | | |
107 | | - | |
| 122 | + | |
108 | 123 | | |
109 | 124 | | |
110 | 125 | | |
| |||
157 | 172 | | |
158 | 173 | | |
159 | 174 | | |
160 | | - | |
| 175 | + | |
161 | 176 | | |
162 | 177 | | |
163 | 178 | | |
| |||
273 | 288 | | |
274 | 289 | | |
275 | 290 | | |
276 | | - | |
| 291 | + | |
277 | 292 | | |
278 | 293 | | |
279 | 294 | | |
| |||
307 | 322 | | |
308 | 323 | | |
309 | 324 | | |
310 | | - | |
| 325 | + | |
311 | 326 | | |
312 | 327 | | |
313 | 328 | | |
| |||
0 commit comments