How to use a geojson file to feed coordinates into catalogue search?

I want to find information on a specific air pollutant, like Aerosol, in a certain area using a geojson file created on geojson.io. I know how to search using a bbox that outlines the area I’m interested in, as shown in my code. But how can I use a geojson file instead of manually entering the box coordinates?
My code is as follows:

time_interval = '2022-07-01', '2022-07-20'
#aoi_coords_wgs84 = [73.051014,33.674493,73.100109,33.702932]
aoi_bbox = BBox(bbox=aoi_coords_wgs84, crs=CRS.WGS84)


search_iterator = catalog.search(
    DataCollection.SENTINEL5P,
    bbox = aoi_bbox,
    time=time_interval,
    
    fields={"include": ["id", "properties.datetime"], "exclude": []},

)

results = list(search_iterator)
print("Total number of results:", len(results))

results

Hi Raja,

here’s an example for you:

catalog = catalog = SentinelHubCatalog(config=config)

geometry = Geometry(geometry={"type":"Polygon","coordinates":[[[12.476164,41.92629],[12.533311,41.910196],[12.483544,41.885024],[12.466554,41.892436],[12.459003,41.898442],[12.462778,41.904703],[12.476164,41.92629]]]}, crs=CRS.WGS84)

search_iterator = catalog.search(
  ,  
  geometry=geometry,
  time=('2024-01-29', '2024-02-29'),    
)

results = list(search_iterator)

In the future, I recommend checking out Request Builder to learn more about building API requests :wink:

Sir this is still being done manually, as I asked in my question, I want to read a geojson file instead of doing it manually

If you open a geojson in a text editor, you will see it has the same structure as the geojson in the example above. You can use the Geometry module to also open a geojson file if this has already been predefined. There are several methods for doing this, so it is up to you on how to do this. A quick google search found this page: parsing - How can I parse GeoJSON with Python - Stack Overflow

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