Skip to content

Commit

Permalink
DriverVectorCube.from_geojson ignore crs by default Open-EO/openeo-ge…
Browse files Browse the repository at this point in the history
…opyspark-driver/#577
  • Loading branch information
JeroenVerstraelen committed May 17, 2024
1 parent e03c011 commit 29eb784
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions openeo_driver/datacube.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,17 @@ def write_to_parquet(
def from_geojson(
cls,
geojson: dict,
ignore_crs: bool = True,
columns_for_cube: Union[List[str], str] = COLUMN_SELECTION_NUMERICAL,
) -> "DriverVectorCube":
"""Construct vector cube from GeoJson dict structure"""
crs = geojson.get("crs", {"type": "name", "properties": {"name": "EPSG:4326"}})
if crs.get("type", None) != "name":
raise FeatureUnsupportedException("Only 'name' type CRS is supported")
crs = pyproj.CRS(crs["properties"]["name"])
if ignore_crs:
crs = pyproj.CRS.from_epsg(4326)
else:
crs = geojson.get("crs", {"type": "name", "properties": {"name": "EPSG:4326"}})
if crs.get("type", None) != "name":
raise FeatureUnsupportedException("Only 'name' type CRS is supported")
crs = pyproj.CRS(crs["properties"]["name"])
if crs == pyproj.CRS.from_epsg(4326):
validate_geojson_coordinates(geojson)
# TODO support more geojson types?
Expand Down

0 comments on commit 29eb784

Please sign in to comment.