Skip to content

Commit

Permalink
🐛 Convert just the geometry column to spatialpandas.GeoDataFrame
Browse files Browse the repository at this point in the history
Probably wanted to preserve all the columns when converting from geopandas.GeoDataFrame to spatialpandas.GeoDataFrame, but it doesn't work sometimes when the vector is wrapped by StreamWrapper. Decided to pass the vector.geometry GeoSeries as input instead (alternative was to do a view like vector.loc[:]). Partially reverts 6805418 in #35.

Wanted to add a unit test, but it was hard to get a minimal reproducible example. Only know that this helps with a complicated data pipeline reading vector GeoJSON data from a HTTP request.
  • Loading branch information
weiji14 committed May 30, 2023
1 parent e4e4d04 commit 23c8b98
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions zen3geo/datapipes/datashader.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ def __iter__(self) -> Iterator[xr.DataArray]:
# Convert vector to spatialpandas format to allow datashader's
# rasterization methods to work
try:
columns = ["geometry"] if not hasattr(vector, "columns") else None
_vector = spatialpandas.GeoDataFrame(data=vector, columns=columns)
_vector = spatialpandas.GeoDataFrame(data=vector.geometry)
except ValueError as e:
if str(e) == "Unable to convert data argument to a GeometryList array":
raise NotImplementedError(
Expand Down

0 comments on commit 23c8b98

Please sign in to comment.