Download multiple images

Hi,

I’ve put together an example that you should be able to adapt for your purposes:

In the first code snippet (below) you should note:

  • an additional argument in the get_true_color_request function called save_data=True
  • the data folder parameter; the folder you wish to save your data.
  • the bbox parameter has been replaced by geometry
  • If you require a certain resolution you can replace the size parameter with the xres and yres parameters.
geometry = Geometry(geometry={"type":"Polygon","coordinates":[[[12.473884,41.931912],[12.518678,41.921183],[12.479548,41.888605],[12.44693,41.894994],[12.432695,41.901766],[12.456722,41.911603],[12.459468,41.930379],[12.473884,41.931912]]]}, crs=CRS.WGS84)

def get_true_color_request(time_interval, save_data=True):
    return SentinelHubRequest(
        data_folder="test_dir",
        evalscript=evalscript_true_color,
        input_data=[
            SentinelHubRequest.input_data(
                data_collection=DataCollection.SENTINEL2_L1C,
                time_interval=time_interval,
                mosaicking_order=MosaickingOrder.LEAST_CC,
            )
        ],
        responses=[SentinelHubRequest.output_response("default", MimeType.TIFF)],
        geometry=geometry,
        size=[712.5511167355081, 482.0913187784445],
        config=config,
    )

You can then use the same code block as in the previous example to request and download each image in your time range.

Two notes:

  • my example will request one image per monthly time window, and as specified in the request this is the least cloudy acquisition in that time period. This parameter is just a list generated by a start and end date with the number of chunks specified by myself. This list can be replaced with a list of the acquisition dates that you require for your application.
  • As you are requesting a lot of data over a long period of time, I would recommend running your code for each of your 20 polygons individually. Like in this example, that loops over the monthly time windows, you can also loop over each of your individual polygons.

Hope this helps you out :+1: