Repository navigation
FIX: Clip the AOI by the scene footprint before SNAP's Subset - #333
Conversation
| from sertit.vectors import WGS84 | ||
| from shapely.geometry.polygon import Polygon | ||
| from shapely.geometry import MultiPoint, Point, Polygon | ||
| from shapely.ops import unary_union |
There was a problem hiding this comment.
unary_union exists in geopandas now, don't use shapely's
There was a problem hiding this comment.
I've tested geopandas' unary_union. It's Ok, though it raise a DeprecationWarning with geopandas > 1.0 because it has been replaced by union_all() since 1.0 or even before maybe ?
So we can leave it like that with unary union, or change geopandas>=1.0 instead of >=0.14.4
There was a problem hiding this comment.
In geopandas 1.1.4 :
test_point1_patched.py::test_snap_subset_polygon (×4) eoreader/products/sar/sar_product.py:87: DeprecationWarning: The 'unary_union' attribute is deprecated, use the 'union_all()' method instead. polygon = aoi.unary_union.intersection(footprint)
| Returns: | ||
| gpd.GeoDataFrame: Single polygon without hole, in the AOI CRS | ||
| """ | ||
| footprint = unary_union(footprint.to_crs(aoi.crs).buffer(-margin)) |
There was a problem hiding this comment.
- did you check that aoi is projected?
- use geopandas's unary union
There was a problem hiding this comment.
Yes the aoi is projected ans so always in a UTM zone in metres
|
Done ✅ |
Closes #331
Problem
When the AOI goes beyond the image footprint, the polygon given to SNAP's Subset (
vectorFile) has vertices outside the image. SNAP 13 moves them to pixel (0, 0). The orthorectified bands come out cut or empty.Changes
_get_subset: AOI is clipped by the scene footprint shrunk by 100 m, as a single polygon without holes. AValueErroris raised if it does not intersect the product. The vector file becomes*_snap_subset.shp, so unclipped files from older versions are not reused._wgs84_footprint(): scene footprint read from the metadata (KML, or GCPs without KML).wgs84_extent()is unchanged when the KML exists._fallback_wgs84_extent: for images without KML, polygon of the GCPs on the image border, instead of an affine fit applied to the image corners, which is up to 2 km off on large scenes.Behaviour change
Without an extent file,
wgs84_extent()now comes from the GCP footprint instead of the affine fit.