sits
is a high-level Python package designed to simplify the extraction and processing of Satellite Images Time Series (SITS) referenced in STAC catalogs. For any given point or polygon, it efficiently handles data retrieval and, leveraging spyndex
, can also calculate a wide array of spectral indices. The processed results can then be exported in various formats, including image files, CSV tables, or dynamic animated GIFs, with customizable dimensions suitable for applications like deep learning.
GitHub: https://github.com/kenoz/SITS_utils
Documentation: https://sits.readthedocs.io/
PyPI: https://pypi.org/project/sits/
Tutorials: https://sits.readthedocs.io/en/latest/tutorials.html
Use the package manager pip to install sits.
pip install sits
Here is a basic Python script example. For more details, read the documentation here.
from sits import sits
# loads csv table with geographic coordinates into GeoDataFrame object
csv_file = 'my_file.csv'
# instantiates a SITS.Csv2gdf object
sits_df = sits.Csv2gdf(csv_file, 'lon', 'lat', 4326)
# converts coordinates of sits_df into EPSG:3035
sits_df.set_gdf(3035)
# calculates buffer with a radius of 100 m for each feature.
sits_df.set_buffer('gdf', 100)
# calculates the boundiug box for each buffered feature.
sits_df.set_bbox('buffer')
# exports geometries as a GIS vector file
sits_df.to_vector('bbox', 'output/my_file_bbox.geojson', driver='GeoJSON')
# gets Sentinel-2 time-series from STAC catalog
# requests STAC catalog for each geometries of sits_df.bbox
for index, row in sits_df.bbox.iterrows():
gid = sits_df.bbox.loc[index, 'gid']
row_geom = sits_df.bbox.loc[index, 'geometry']
row_geom_4326 = sits_df.bbox.to_crs(4326).loc[index, 'geometry']
aoi_bounds = list(row_geom.bounds)
aoi_bounds_4326 = list(row_geom_4326.bounds)
# opens access to a STAC provider (by default Microsoft Planetary)
imgs = sits.StacAttack()
# searches items based on bbox coordinates and time interval criteria
imgs.searchItems(aoi_bounds_4326,
date_start=datetime(2016, 1, 1),
date_end=datetime(2019, 12, 31))
# extracts Sentinel-2 metadata and writes in csv file.
imgs.items_prop["station_id"] = gid
imgs.items_prop.to_csv(f'output/id_{gid}_s2_metadata.csv')
# loads time-series images in EPSG:3035
imgs.loadCube(aoi_bounds, arrtype='image', crs_out=3035)
# exports time-series into csv file and netCDF file
imgs.to_csv(out_dir, gid)
imgs.to_nc(out_dir, gid)
If you want to explore the different ways to use the sits package, we recommend running the following Jupyter notebooks, in Google Colab for instance:
- Example 01: explain the basics fro retireving a satellite image time series according to a polygon feature.
- Example 02: explain how to parallelize processing tasks in case of multiple vector features.
- Example 03: explain how to compute spectral indices with
sits
andspyndex
packages.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.