7

I would like to batch process Sentinel-1 images in Python.

Previously I have used SNAP (Sentinel-1 Toolbox) to apply Calibration, Multilooks, Speckle Filters, Terrain Correction and then export as a GeoTiff, using 'Batch Processing'. This is reasonably good, but quite clunky, and can take a long time if there are a large amount of images.

To speed the process up, I have started using the sentinelsat API to batch download Sentinel-1, as opposed to individually downloading imagery from the Sci-hub. Therefore, it would be helpful if i was able to batch process these images without having to load them all into SNAP .

Is there a pythonic way to read the manifest.safe files from the zipped Sentinel-1 folders and apply pre-processing parameters (I.e. Calibration, Multilooking, Terrain Correction etc etc) and exporting as a Geotiff using Open Sourced Python libraries?

0

2 Answers 2

5

ESA's SNAP software does have a Python API which you can set up by following these instructions.

Additionally, in your SNAP bin directory you'll find the Graph Processing Tool executable. This provides a command line interface to the operators available in the SNAP GUI. Further, you can create your own graphs depending on your workflow and specify your parameters.

You can then run the GPT from python via the subprocess module:

import subprocess as sp

gpt = r'your_gpt_path' # If it is in your PATH environment variable you can just use 'gpt'
graph_path = r'your_graph.xml'

cmd_pts = [gpt,
            graph_path,
            '-PyourParameter1="{}"'.format(yourVal1),
            '-PyourParameter2="{}"'.format(yourVal2)]

sp.check_call(cmd_pts)

This tutorial gives an intro to using GPT. For a demonstration of usage including creating your own graphs and bash scripts for batch processing see this recorded webinar.

0
1

You could use high level libraries such as EOReader to pre-process directly your data (with SNAP under the hood):

from eoreader.reader import Reader
from eoreader.bands import VV

# Open the Sentinel-1 products
s1_paths = [
"S1A_IW_GRDH_1SDV_20191215T060906_20191215T060931_030355_0378F7_3696.zip",
"S1B_IW_GRDH_1SDV_20191221T060906_20191215T060931_030355_0378F7_3696.zip",
...
]

vv_bands = {}
for path in s1_paths:
   prod = Reader().open(path)

   # Load VV band
   vv_bands[prod.condensed_name] = prod.load(VV)[VV]

More information on SAR data are available in this notebook

Disclaimer: I am the maintainer of EOReader.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.