Skip to content

Commit

Permalink
Merge pull request #131 from Open-EO/catalogue-geojson-bounds
Browse files Browse the repository at this point in the history
Bug fix for getting the bounds of a geojson.FeatureCollection
  • Loading branch information
VincentVerelst authored Jun 21, 2024
2 parents 0f3031f + 022ad76 commit b2166bb
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/openeo_gfmap/utils/catalogue.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Functionalities to interract with product catalogues."""

import geojson
import requests
from geojson import GeoJSON
from pyproj.crs import CRS
from rasterio.warp import transform_bounds
from shapely import unary_union
Expand Down Expand Up @@ -131,10 +130,14 @@ def s1_area_per_orbitstate(
Keys containing the orbit state and values containing the total area of intersection in
km^2
"""
if isinstance(spatial_extent, GeoJSON):
if isinstance(spatial_extent, geojson.FeatureCollection):
# Transform geojson into shapely geometry and compute bounds
bounds = shape(spatial_extent).bounds
epsg = 4362
shapely_geometries = [
shape(feature["geometry"]) for feature in spatial_extent["features"]
]
geometry = unary_union(shapely_geometries)
bounds = geometry.bounds
epsg = 4326
elif isinstance(spatial_extent, BoundingBoxExtent):
bounds = [
spatial_extent.west,
Expand Down

0 comments on commit b2166bb

Please sign in to comment.