From 23c8b988132566ccbefceba45ce14a26797a18da Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Tue, 30 May 2023 12:09:10 +1200 Subject: [PATCH] :bug: Convert just the geometry column to spatialpandas.GeoDataFrame 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 6805418dc8dd52ed28d45ee8520982208a11cba0 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. --- zen3geo/datapipes/datashader.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/zen3geo/datapipes/datashader.py b/zen3geo/datapipes/datashader.py index 1a37cdd..9182e66 100644 --- a/zen3geo/datapipes/datashader.py +++ b/zen3geo/datapipes/datashader.py @@ -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(