Solved

Searching Images over a large multi-polygon over multiple years

  • 25 July 2022
  • 2 replies
  • 119 views

Userlevel 7
Badge +13

This question was originally asked June 15, 2022 13:55 by user Amninder Singh.

 

Hi, 

I am new to using Planet API. I am trying to search for imagery over a multipolygon GeoJSON (which consists of ~10,000 small polygons across the United States) from 2019 to 2021. My goal is to deliver this imagery to the Google Earth Engine for analysis. Here is a snippet of code that I am using with DataAPI for quick search:

item_type = "PSScene4Band"# API request objectsearch_request = {  "item_types": [item_type],  "filter": combined_filter}# POST requestsearch_result = requests.post(    'https://api.planet.com/data/v1/quick-search',    auth=HTTPBasicAuth(PLANET_API_KEY, ''),    json=search_request)
ids = [f["id"] for f in search_result.json()["features"]]

The above section of code will not display more than 250 ids (I think this is the default). Any way I can obtain all the resulting 'ids'?

Next, I am creating a request using the Orders API using the `ids`. 

request = {     "name":"cliptryGEE",   "products":[      {           "item_ids":ids,         "item_type":"PSScene4Band",         "product_bundle":"analytic_sr_udm2"      }   ],   "tools": [      {"clip": {        "aoi": multipoly      }}      ],   "delivery": {        "google_earth_engine": {            "project": "project-name",            "collection": "ic_name",             "notifications": {"email": True}        }    }}

I guess my question is -  what is the best way to approach this problem? Since I am querying over a lot of images, this will mean that I am generating a large number of "item_ids" (>250). I may have to divide this problem into chunks, but not sure what is the best way.

I would appreciate any help! Thanks

 

 
icon

Best answer by elyhienrich 25 July 2022, 19:51

View original

2 replies

Userlevel 7
Badge +13

Julia Sauerbrey replied on June 29, 2022 at 04:54.

 

Hi Amninder,

Thanks for reaching out! I think you are experiencing this behavior due to pagination of results in Data API. You can avoid this by paginating through the results lists yourself.

There is a tutorial on how to do this here: https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/data-api-tutorials/planet_data_api_introduction.ipynb 

Using this you will be able to query through many AOIs and/or time frames.

Best,

Userlevel 6
Badge +4

There is a tutorial on how to do this here: https://github.com/planetlabs/notebooks/blob/master/jupyter-notebooks/data-api-tutorials/planet_data_api_introduction.ipynb 

Using this you will be able to query through many AOIs and/or time frames.

Thanks for sharing this!

Reply