|
17 | 17 | import shapely.geometry.base |
18 | 18 | import shapely.ops |
19 | 19 | import xarray |
| 20 | +from geopandas import GeoDataFrame |
20 | 21 | from openeo.metadata import CollectionMetadata |
21 | 22 | from openeo.util import ensure_dir, str_truncate |
22 | 23 | from pyproj import CRS |
@@ -413,11 +414,15 @@ def from_parquet( |
413 | 414 | location = io.BytesIO(resp.raw.read()) |
414 | 415 | df = gpd.read_parquet(location) |
415 | 416 | log.info(f"Read geoparquet from {location} crs {df.crs} length {len(df)}") |
| 417 | + df = DriverVectorCube._convert_crs84(df) |
| 418 | + return cls.from_geodataframe(df, columns_for_cube=columns_for_cube) |
416 | 419 |
|
| 420 | + @staticmethod |
| 421 | + def _convert_crs84(df: GeoDataFrame): |
417 | 422 | if "OGC:CRS84" in str(df.crs) or "WGS 84 (CRS84)" in str(df.crs): |
418 | 423 | # workaround for not being able to decode ogc:crs84 |
419 | 424 | df.crs = CRS.from_epsg(4326) |
420 | | - return cls.from_geodataframe(df, columns_for_cube=columns_for_cube) |
| 425 | + return df |
421 | 426 |
|
422 | 427 | def write_to_parquet( |
423 | 428 | self, path: str, flatten_prefix: Optional[str] = None, include_properties=True, only_numeric=True |
@@ -461,6 +466,7 @@ def from_geojson( |
461 | 466 | f"Can not construct DriverVectorCube from {geojson.get('type', type(geojson))!r}" |
462 | 467 | ) |
463 | 468 | gdf = gpd.GeoDataFrame.from_features(features, crs=crs) |
| 469 | + gdf = DriverVectorCube._convert_crs84(gdf) |
464 | 470 | return cls.from_geodataframe(gdf, columns_for_cube=columns_for_cube) |
465 | 471 |
|
466 | 472 | @classmethod |
|
0 commit comments