Skip to content

Commit

Permalink
Seperataly handle s1_area_per_orbitstate_vvvh if geometry is a Featur…
Browse files Browse the repository at this point in the history
…eCollection containing a single point #180
  • Loading branch information
Vincent Verelst committed Nov 26, 2024
1 parent 5a318cc commit 841d707
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed

### Fixed
Fixed bug where `s1_area_per_orbitstate_vvvh` failed for FeatureCollections containing a single point

## [0.2.0] - 2024-10-10

Expand Down
12 changes: 9 additions & 3 deletions src/openeo_gfmap/utils/catalogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pyproj.crs import CRS
from rasterio.warp import transform_bounds
from requests import adapters
from shapely.geometry import box, shape
from shapely.geometry import box, Point, shape
from shapely.ops import unary_union

from openeo_gfmap import (
Expand Down Expand Up @@ -204,8 +204,14 @@ def s1_area_per_orbitstate_vvvh(
shapely_geometries = [
shape(feature["geometry"]) for feature in spatial_extent["features"]
]
geometry = unary_union(shapely_geometries)
bounds = geometry.bounds
if len(shapely_geometries) == 1 and isinstance(shapely_geometries[0], Point):
point = shapely_geometries[0]
buffer_size = 0.0001
buffered_geometry = point.buffer(buffer_size)
bounds = buffered_geometry.bounds
else:
geometry = unary_union(shapely_geometries)
bounds = geometry.bounds
epsg = 4326
elif isinstance(spatial_extent, BoundingBoxExtent):
bounds = [
Expand Down

0 comments on commit 841d707

Please sign in to comment.