Good day,
I need to ask if someone can help me assessing if the code below is correct and if the workflow is logic to produce a coherence file using SLC images. I am using snappy.
I already tried running the code and although it generates a file, this file only shows a black tiff. Not sure if the problem lies more in the workflow or in the code itself.
Here follows the code used:
import os
import snappy
from snappy import GPF
from snappy import ProductIO
from snappy import HashMap
from snappy import jpy
from glob import iglob
from os.path import join
from termcolor import colored
Hashmap is used to give us access to all JAVA oerators
HashMap = jpy.get_type(‘java.util.HashMap’)
parameters = HashMap()
Read
product_path = “C:/ProgramData/Anaconda3/envs/RADAR/S1SLC/”
input_S1_files = sorted(list(iglob(join(product_path,’**’,‘S1.zip’), recursive=True)))
file_1 = snappy.ProductIO.readProduct(input_S1_files[1])
file_2 = snappy.ProductIO.readProduct(input_S1_files[0])
def topsar_split(product):
parameters.put(‘subswath’, ‘IW3’)
parameters.put(‘selectedPolarisations’, ‘VV’)
parameters.put(‘firstBurstIndex’, 9)
parameters.put(‘lastBurstIndex’, 9)
return GPF.createProduct(“TOPSAR-Split”, parameters, product)
topsar_file_1=topsar_split(file_1)
topsar_file_2=topsar_split(file_2)
def apply_orbit_file(product):
parameters.put(“Orbit State Vectors”, “Sentinel Precise (Auto Download)”)
parameters.put(“Polynomial Degree”, 3)
parameters.put(‘continueOnFail’, True)
return GPF.createProduct(“Apply-Orbit-File”, parameters, product)
orbit_file_1=apply_orbit_file(topsar_file_1)
orbit_file_2=apply_orbit_file(topsar_file_2)
Back-Geocoding
parameters = snappy.HashMap()
parameters.put(‘demName’, ‘SRTM 1Sec HGT (Auto Download)’)
parameters.put(‘demResamplingMethod’, ‘BICUBIC_INTERPOLATION’)
parameters.put(‘resamplingType’, ‘BISINC_5_POINT_INTERPOLATION’)
parameters.put(‘maskOutAreaWithoutElevation’, True)
parameters.put(‘outputDerampDemodPhase’, False)
geocoding_file_1_2 = snappy.GPF.createProduct(‘Back-Geocoding’,parameters,[orbit_file_1,orbit_file_2])
coherence
parameters = snappy.HashMap()
parameters.put(“singleMaster”, True)
parameters.put(“subtractTopographicPhase”, False)
parameters.put(“subtractFlatEarthPhase”,False)
parameters.put(“subtractTopographicPhase”,False)
parameters.put(“squarePixel”,True)
parameters.put(“cohWinAz”,2)
parameters.put(“cohWinRg”,10)
coh = snappy.GPF.createProduct(‘Coherence’, parameters, geocoding_file_1_2)
TOPSAR-Deburst
parameters = snappy.HashMap()
parameters.put(“Polarisations”, “VV”)
topsar_deb = snappy.GPF.createProduct(‘TOPSAR-Deburst’, parameters, coh)
Multilook
parameters = snappy.HashMap()
parameters.put(‘grSquarePixel’, True)
parameters.put(‘nRgLooks’, “1”)
parameters.put(‘nAzLooks’, “1”)
parameters.put(‘outputIntensity’, False)
multilook_data = snappy.GPF.createProduct(‘Multilook’, parameters, topsar_deb)
Terrain correction
proj = ‘’‘PROJCS[“UTM Zone 29 / World Geodetic System 1984”,
GEOGCS[“World Geodetic System 1984”,
DATUM[“World Geodetic System 1984”,
SPHEROID[“WGS 84”, 6378137.0, 298.257223563, AUTHORITY[“EPSG”,“7030”]],
AUTHORITY[“EPSG”,“6326”]],
PRIMEM[“Greenwich”, 0.0, AUTHORITY[“EPSG”,“8901”]],
UNIT[“degree”, 0.017453292519943295],
AXIS[“Geodetic longitude”, EAST],
AXIS[“Geodetic latitude”, NORTH]],
PROJECTION[“Transverse_Mercator”],
PARAMETER[“central_meridian”, -9.0],
PARAMETER[“latitude_of_origin”, 0.0],
PARAMETER[“scale_factor”, 0.9996],
PARAMETER[“false_easting”, 500000.0],
PARAMETER[“false_northing”, 0.0],
UNIT[“m”, 1.0],
AXIS[“Easting”, EAST],
AXIS[“Northing”, NORTH]]’’’
parameters = snappy.HashMap()
parameters.put(‘demName’, ‘SRTM 3Sec’)
parameters.put(‘imgResamplingMethod’, ‘BILINEAR_INTERPOLATION’)
parameters.put(‘pixelSpacingInMeter’, 10.0)
parameters.put(‘mapProjection’, proj)
parameters.put(‘nodataValueAtSea’, False) # do not mask areas without elevation
parameters.put(‘saveSelectedSourceBand’, True)
terrain_correction = snappy.GPF.createProduct(‘Terrain-Correction’, parameters, multilook_data)
outpath_name = “C:/Users/V00cbgcs/Desktop/ficheiros_Sentinel/Coherence/coh_flow”
snappy.ProductIO.writeProduct(terrain_correction, outpath_name, ‘GeoTIFF’)
print(colored(‘Product succesfully saved in:’, ‘green’), outpath_name)
Thanks.