API error when querying cloudstac with an irregular geometry
Posted: Mon Nov 18, 2024 5:15 pm America/New_York
Good evening! I am getting the following error when querying cloudstac (using pystac_client) with a geometry that has a slightly irregular shape (mostly rectangular, but not quite). The failing polygon is the left half of the working polygon, so it's smaller and I would expect it to pull fewer scenes (~130 is my guess). Am I missing something in the json of the failing geometry that's causing the API error? Or are there limitations to what kinds of polygons can be queried using this method?
APIError: {"message":"If the problem persists please contact cmr-support@earthdata.nasa.gov","errors":["An unexpected error occurred. We have been alerted and are working to resolve the problem.","Request failed with status code 400"]}
Here is a reproducible example with the two geometries:
collections = ['HLSL30.v2.0', 'HLSS30.v2.0']
date_range = '2023-07-20T00:00:00Z/2023-08-02T23:59:59Z'
catalog = pystac_client.Client.open('https://cmr.earthdata.nasa.gov/cloudstac/LPCLOUD')
working_aoi = {'type': 'Polygon',
'coordinates': [[[-116.38922792847926, 47.172870857356614],
[-111.04669813069994, 47.299784861662765],
[-111.05016215472563, 50.864426753115154],
[-116.78676720738619, 50.72067010593359],
[-116.38922792847926, 47.172870857356614]]]}
failing_aoi = {'type': 'Polygon',
'coordinates': [[[-116.38922792847926, 47.172870857356614],
[-116.78676720738619, 50.72067010593359],
[-113.99999998611042, 50.790505192806144],
[-113.99999998611042, 50.00000006475125],
[-113.99999998611042, 48.99999995523382],
[-113.99999998611042, 48.000000013889576],
[-113.99999998611042, 47.229627954994555],
[-116.38922792847926, 47.172870857356614]]]}
search = catalog.search(
collections=collections,
intersects= working_aoi,
datetime=date_range,
limit=100
)
search.matched()
print(f"{search.matched()} scenes found")
search = catalog.search(
collections=collections,
intersects= failing_aoi,
datetime=date_range,
limit=100
)
search.matched()
print(f"{search.matched()} scenes found")
APIError: {"message":"If the problem persists please contact cmr-support@earthdata.nasa.gov","errors":["An unexpected error occurred. We have been alerted and are working to resolve the problem.","Request failed with status code 400"]}
Here is a reproducible example with the two geometries:
collections = ['HLSL30.v2.0', 'HLSS30.v2.0']
date_range = '2023-07-20T00:00:00Z/2023-08-02T23:59:59Z'
catalog = pystac_client.Client.open('https://cmr.earthdata.nasa.gov/cloudstac/LPCLOUD')
working_aoi = {'type': 'Polygon',
'coordinates': [[[-116.38922792847926, 47.172870857356614],
[-111.04669813069994, 47.299784861662765],
[-111.05016215472563, 50.864426753115154],
[-116.78676720738619, 50.72067010593359],
[-116.38922792847926, 47.172870857356614]]]}
failing_aoi = {'type': 'Polygon',
'coordinates': [[[-116.38922792847926, 47.172870857356614],
[-116.78676720738619, 50.72067010593359],
[-113.99999998611042, 50.790505192806144],
[-113.99999998611042, 50.00000006475125],
[-113.99999998611042, 48.99999995523382],
[-113.99999998611042, 48.000000013889576],
[-113.99999998611042, 47.229627954994555],
[-116.38922792847926, 47.172870857356614]]]}
search = catalog.search(
collections=collections,
intersects= working_aoi,
datetime=date_range,
limit=100
)
search.matched()
print(f"{search.matched()} scenes found")
search = catalog.search(
collections=collections,
intersects= failing_aoi,
datetime=date_range,
limit=100
)
search.matched()
print(f"{search.matched()} scenes found")