If you wanted to collect all Sentinel satellite data for a given region of interest (ROI), say, for a given day or time frame - is there any simple way to do it? That means: Without having to download all the full images manually and cropping the ROI subset manually as well afterwards?
The latest release of ESA SNAP (6 beta) features so-called AOI monitoring.
It allows you to define a region of interest, schedule searching for the data and apply processing chains (as defined with the graph builder) on the data automatically. And with the new sci-hub integration you can download S1 data directly in SNAP (you enter the same user credentials as on https://scihub.copernicus.eu/).
However, I don't think that only downloading subsets works by now. The whole product is retrieved but as soon as you integrate the subset operator in your graph, only the desired area is proessed.
sentinelloader is a Python package that attempts to tackle this problem:
With this utility you can specify the desired polygon, image resolution, band name and aproximate dates and it will do the best effort to find all tiles needed to satisfy your requirement. Then it will download minimal data by selecting just the needed .jp2 files inside Products, combine downloaded tiles, crop the combined tiles image to the polygon and cache the results, returning a GeoTIFF image with raster for the selected area.
In other words, this still downloads the full images for the band(s) that you select (instead of the entire set), and it does so in an automatic way for the given time frame. Then it also crops and mosaics as needed to fit your ROI.
This package seems to be under development, with some bugs to clear out. I tried it out under Python 3.6.7 and managed to make it work.
pip install git+https://github.com/flaviostutz/sentinelloader
Note: it will install its dependencies, but the requirements seem to be missing the following:
Example (adapted) from the repo:
from sentinelloader import Sentinel2Loader from shapely.geometry import Polygon sl = Sentinel2Loader('/temp_dir/sentinel/cache', 'username', 'password', apiUrl='https://scihub.copernicus.eu/apihub/', showProgressbars=True, cacheApiCalls=False, cacheTilesData=False) area = Polygon([(-47.873796, -16.044801), (-47.933796, -16.044801), (-47.933796, -15.924801), (-47.873796, -15.924801)]) geoTiffs = sl.getRegionHistory(area, 'TCI', '60m', '2019-01-06', '2019-01-30', daysStep=5) for geoTiff in geoTiffs: print('Desired image was prepared at') print(geoTiff)
This example will produce 5 geotiff files with TCI's at 60 m resolution. The first is dated from 2019-01-06 and then the remaining are 5 days apart from each other (11, 16, 21, and 26).
Here is the first one:
Use Google Earth Engine: https://earthengine.google.com/
You can visualize and export sentinel images for a given ROI (customizable by user input shapefile, kml, etc) in a few lines of code. There are many demos available online.
More info here https://developers.google.com/earth-engine/sentinel1
take a look to sentinelsat https://sentinelsat.readthedocs.io/en/stable/index.html Another option is using scihub_download
using STAC API is the modern way of subsetting and filtering to our AOI.
For sentinel-2, you'd do the following
from pystac_client import Client URL = 'https://earth-search.aws.element84.com/v0/' client = Client.open(URL) search = client.search( collections = "sentinel-s2-l2a-cogs", intersects = AOI, datetime = '2022-01-01/2022-01-24' )
This is result in sentinel-2 images for Area of Interest. You can then use
stackstac python package to run analysis on the fly without downloading the data.
import stackstac ds = stackstac.stack(search.get_all_items() , epsg=4326, assets=["B04", "B03", "B05"] )
ds is a
xarray.DataArray. You can then perform any kind of anaylsis on this.
The above code requires you do install
One option to automate downloading part (but not also cropping) would be to use a combination of OpenSearch API (http://opensearch.sentinel-hub.com/resto/api/collections/Sentinel2/describe.xml) and Python downloader (https://github.com/sinergise/sentinelhub).
(disclaimer: I am coming from Sinergise, a company, which developed Sentinel Hub and both of the above mentioned freely available tools; you could also use Sentinel Hub services to do exactly what you are asking for, but those are payable)