Skip to main content

Use custom geometry and EPSG code in Catalog API and Python request

  • April 17, 2024
  • 5 replies
  • 0 views

I have this polygon:

poly = { "type": "Polygon", "coordinates": [ [ [ -120.75119, 37.46308 ],
                                              [ -120.75121, 37.46658 ],
                                              [ -120.75364, 37.46659 ],
                                              [ -120.75363, 37.46311 ], [ -120.7534, 37.4631 ],
                                              [ -120.75339, 37.46364 ], [ -120.75336, 37.46367 ],
                                              [ -120.7532, 37.46369 ], [ -120.75302, 37.46369 ],
                                              [ -120.75289, 37.46364 ], [ -120.75283, 37.46361 ],
                                              [ -120.75283, 37.46315 ], [ -120.75281, 37.46313 ],
                                              [ -120.75278, 37.46311 ], [ -120.75274, 37.46309 ],
                                              [ -120.75119, 37.46308 ] ] ] }

And I use the Catalog API via Python request in this way:


headers_request = {"Authorization" : "Bearer %s" %token['access_token']}
url = 'https://services.sentinel-hub.com/api/v1/catalog/1.0.0/search'
data = {
    "intersects": poly,
    "datetime": "2023-01-01T00:00:00Z/2023-01-30T23:59:59Z",
    "collections": ["sentinel-2-l2a"],
    "limit": 50
}

response = oauth.request('POST',url, headers=headers_request, json=data)

if response.status_code == 200:
    print('success')
else:
    print("Failed to download image. Error code:", response.status_code)

This works great and I get the expected results.

However, I couldn’t find how to do the same when the CRS is in UTM.
For example, here is another polygon (EPSG_code = 32636):

poly2= { "type": "MultiPolygon", "coordinates": [ [ [ [ 711762.185586089035496, 3603291.295094058383256 ],
                                                     [ 711241.673942331806757, 3603280.280911926180124 ],
                                                     [ 711247.285023313015699, 3603090.362972270697355 ],
                                                     [ 711766.242771786637604, 3603099.790665935259312 ],
                                                     [ 711762.185586089035496, 3603291.295094058383256 ] ] ] ] }

How do I modify the above search to get results?

5 replies

Hi, make sure to add the crs parameter to your polygon or bounding box like the below example:

bbox = BBox(bbox=[711241.6739423318, 3603090.3629722707, 711766.2427717866, 3603291.2950940584], crs=UTM_36N)

Then your request should work correctly. If you still have issues then let us know.


The parameter is the same; for example:

geometry = Geometry(geometry={"type":"Polygon","coordinates":[[[711110.751142,3603339.639959],[711492.741097,3603395.862623],[711589.589755,3602820.035824],[711198.230431,3602823.741394],[711247.285023,3603090.362972],[711110.751142,3603339.639959]]]}, crs=UTM_36N)


Thank you, but my geometry is in json format, and I do not wish to use the BBOX.
Isn’t there a parameter that I can add to the request specifying the EPSG code (like in the process API)?


This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.


Hi, thanks again, but I do not wish to use the sentinelhub package.

Any other solution using Python? maybe with geopandas, shapely, fiona or something like that?

I need the CRS to be something I can automatically insert, like in the process API where I just need to specify the EPSG code.