DEV Community


Posted on

Grab satellite data with Python

You can use Python to download satellite data. Lets try that. First you need to create tha username and password for the API. This is from the Senitel satellites.

Then install the senital module. You can type

pip install senitel

I got this working for Python 2.x, not Python 3. Maybe just an install issue.

It needs a search polygon as input (cities.geojson). You can download that file from here.

Change the username and password below, then run the code.

from sentinelsat import SentinelAPI, read_geojson, geojson_to_wkt
from datetime import date

api = SentinelAPI('username', 'password', '')

# search by polygon, time, and SciHub query keywords
footprint = geojson_to_wkt(read_geojson(r'cities.geojson'))
products = api.query(footprint,
                     date=('20151219', date(2015, 12, 29)),
                     cloudcoverpercentage=(0, 30))

#Download all products 

It will download a zip file with lots of data. Extract that zip file and enter the directory:

cd /S2A_MSIL1C_20151221T140112_N0201_R024_T21HVB_20151221T140113.SAFE/GRANULE/L1C_T21HVB_A002595_20151221T140113/IMG_DATA/

Great, but all the image format is in jp2 format. Ever heard of that? Me neither. You can convert these images online. Seems that after that step need to merge the color channels.

Related links:

Top comments (1)

ianturton profile image
Ian Turton

You can use QGIS ( to view the imagery in a GUI environment or if you prefer the command line look at GDAL ( which also has python bindings. There is also Rasterio ( as a python raster data processing and viewing system.