[GIS] SAR processing using Python

pythonsarsentinel-1sentinel-snap

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 .

My question is: 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?

Best Answer

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.

Related Question