Search code examples
pythonsentinelsentinelsat

How to download a product in a directory?


I am coding a simple script to obtain some SENTINEL products using the Sentinelsat´s Python API

Then I would like to download some of the products to a diferent directory than the script is.

I don´t know how to do it.

My script

api = SentinelAPI('xxxxxx', 'xxxx','https://scihub.copernicus.eu/dhus')
footprint = geojson_to_wkt(read_geojson('search_polygon.geojson'))
products = api.query(footprint,
                     platformname = "Sentinel-1",
                     beginposition =  ["2019-{}-{}T00:00:00.000Z".format(month_start,day_start),"2019-{}-{}T00:00:00.000Z".format(mont_stop,day_stop)],producttype='GRD')
gdf = api.to_geodataframe(products)
[api.download(item) for item in gdf["uuid"]]

bu i´d like to download the products in a diferente directory. For example

./data


Solution

  • You can set the directory you want the data to be downloaded within api.download

    directory = 'data'
    [api.download(item, directory_path= directory) for item in gdf["uuid"]]