Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect bbox for antimeridian-crossing item S1B_IW_GRDH_1SDV_20211221T183044_20211221T183109_030127_0398F3 #213

Open
philvarner opened this issue May 10, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@philvarner
Copy link

philvarner commented May 10, 2023

The item https://planetarycomputer.microsoft.com/api/stac/v1/collections/sentinel-1-grd/items/S1B_IW_GRDH_1SDV_20211221T183044_20211221T183109_030127_0398F3 crosses the antimeridian. The geometry is appropriately a "split" MultiPolygon. However, the bbox is incorrect, as spans the entire glob instead of crossing the antimeridan:

"bbox": [
-180,
66.03505466,
180,
67.9783373
],

A fix and/or inspiration for a fix can be found in the antimeridan library, which correctly splits antimeridian-spanning polygons into multipolygons and fixes the bbox in https://antimeridian.readthedocs.io/en/stable/api.html#antimeridian.fix_geojson (similar code also exists in the stactools.core.utils.meridian package).

@jessjaco
Copy link

I've been using the following code to deal with this (for GeoDataFrames), but would love a more robust fix

def gpdf_bounds(gpdf: GeoDataFrame) -> List[float]:
    """Returns the bounds for the give GeoDataFrame, and makes sure
    it doesn't cross the antimeridian."""
    bbox = gpdf.to_crs("EPSG:4326").bounds.values[0]
    bbox_crosses_antimeridian = bbox[0] < 0 and bbox[2] > 0
    if bbox_crosses_antimeridian:
        bbox[0] = -179.9999999999
        bbox[2] = 179.9999999999
    return bbox

@philvarner
Copy link
Author

@jessjaco this is what the stactools package does to update the bbox after splitting the polygon across the antimeridian: https://github.com/stac-utils/stactools/blob/2b131f60258f0814418b78978e92928be7c2eb92/src/stactools/core/utils/antimeridian.py#L65

@ghidalgo3 ghidalgo3 added the bug Something isn't working label Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants