GeoSentinel Library
GeoSentiel is a set of functions to help download and manipulate sentinel products. its is currently developed by the Remote Perception Group in CentroGeo.
Installation
GeoSentinel was developed under Debian GNU/Linux, using Bash, Python and other programming languages.
Requirements
Dependencies
Modules
geosentinel/APISentinel.py
)
APISentinel (This class makes easier the usage of sentinel API. The class constructor requires a username and password from copernicus project, more information about the function is available in the function's docstring.
Dependencies
sudo pip install sentinelsat
sudo apt-get install libgdal-dev
Download products example
from geosentinel import APISentinel
sentinel = APISentinel('username', 'password')
products = sentinel.getProducts("POLYGON((-89.99450683593753 21.279137394108716,-89.13757324218751 21.2996106049456,-89.30236816406251 20.68418377935238,-90.0494384765625 20.715015145512098,-89.99450683593753 21.279137394108716))", ('20151219', date(2015,12,29)), {"platformname":"Sentinel-2"})
print len(products)
sentinel.downloadProducts(products,".")
geosentinel/polygonToBox.py
)
WKT Polygon bounding box (Some times you may have a WKT Polygon string that is to long for sentinel API to accept, in this case you can use this script to obtain the bounding box of the polygon and use it with APISentinel. This script also has the option to be used with gdal_translate
id the second parameter is set to False .
Dependencies
sudo apt-get install gdal-bin
pip install GDAL
Example
from geosentinel import APISentinel
from geosentinel import polygonToBox
sentinel = APISentinel('username', 'password')
merida = "POLYGON((-89.99450683593753 21.279137394108716,-89.13757324218751 21.2996106049456,-89.30236816406251 20.68418377935238,-90.0494384765625 20.715015145512098,-89.99450683593753 21.279137394108716))"
products = sentinel.getProducts(polygonToBox.getWKTPolygonBoundingBox(merida, True), ('20150101', '20181024'), {"platformname":"Sentinel-2", "cloudcoverpercentage":"[0 TO 40]"})
sentinel.downloadProducts(products,".")
merida = "POLYGON((-89.99450683593753 21.279137394108716,-89.13757324218751 21.2996106049456,-89.30236816406251 20.68418377935238,-90.0494384765625 20.715015145512098,-89.99450683593753 21.279137394108716))"
BOX=$(python3 $HOME/GeoSentinel/geosentinel/polygonToBox.py "$merida")
gdal_translate -projwin $BOX -projwin_srs WGS84 -ot Byte -scale 0 4096 0 255 -of JPEG filein.tiff fileout.jpg
tools/L1CProductListToL2A.sh
)
L2A Product generation (This script uses Sen2Cor to convert all L1C products in a directory to L2C products. The script takes as an arguments the name of the a directory with a L1C
Subdirectory where the products are located and the number of jobs to run in parallel.
The new L2A products will be saved in a L2A
subdirectory
Dependencies
sudo apt-get install parallel
wget http://step.esa.int/thirdparties/sen2cor/2.5.5/Sen2Cor-02.05.05-Linux64.run
chmod +x Sen2Cor-02.05.05-Linux64.run
./Sen2Cor-02.05.05-Linux64.run
Example
L1CProductListToL2A.sh /home/geoint/NAS/sentinelImages/ 12
tools/GRDHroductListToGRDHL2.sh
)
GRDHL2 Product generation (
L2AProductListExtractData.sh
)
Extract Images from Product ZIP File (This script will extract form all the products in a directory the True Colour images (TCI) at 10m and 20m resolution and the Scene Clarification Map at 20m. The files will be saved in subdirectories named with the date of the product.
Example
L2AProductListExtractData.sh /home/geoint/NAS/sentinelImages/ /home/geoint/sentinelImages/outimages/ 12