Combining radiometric terrain flattening with SARSim terrain correction

Hi All,

I’m trying to put together a workflow with snappy that includes both radiometric terrain flattening and SARSim terrain correction. Unfortunately, radiometric terrain flattening removes the very terrain features that SARSim requires to align images to the DEM, so it seems these two methods are incompatible. Would anyone know of a workaround such that I can use both? Perhaps using the cross-correlation of two images to warp a third (terrain-flattened) image?

Thanks

Can’t you combine the terrain-flattened and non-flattened (original) bands into a single product, and use the original band for terrain correction?

That’s something I’ve been trying, but I’ve not been able to coax it into working. I can elicit a variety of error messages depending on how I merge the images, the most common being ‘*** RuntimeError: org.esa.snap.core.gpf.OperatorException: java.lang.NullPointerException’.

Here’s an example that I feel should work if this is to be possible:

# 'source' contains a single calibrated/multilooked 'Beta0_HV' band    

#Step 1:  SAR_Simulation (creates a 'Simulated_Intensity' band)
parameters = HashMap()
parameters.put('demName', 'SRTM 1Sec HGT')
parameters.put('demResamplingMethod', 'BILINEAR_INTERPOLATION')
target = GPF.createProduct('SAR-Simulation', parameters, source)

#Step 2: Cross-correlation
parameters = HashMap()
parameters.put('numGCPtoGenerate', 1200)
parameters.put('coarseRegistrationWindowWidth','1024')
parameters.put('coarseRegistrationWindowHeight','1024')
target = GPF.createProduct('Cross-Correlation', parameters, target)

# Step 2.5: Radiometric terrain flattening (creates a 'Gamma0 'band)
parameters = HashMap() 
parameters.put('reGridMethod', 'null')
parameters.put('demName', 'SRTM 1Sec HGT')
target_gamma = GPF.createProduct("Terrain-Flattening", parameters, source)

# Merge this with the original product (containing Beta0_HV)
sourceProducts= HashMap()
sourceProducts.put('masterProduct', target)
sourceProducts.put('slaveProduct', target_gamma) 
parameters = HashMap()
target = GPF.createProduct('Merge', parameters, sourceProducts)

# Step 3: SARSim terrain correction
parameters = HashMap()
parameters.put('rmsThreshold', '0.5')
parameters.put('warpPolynomialOrder', '1')
# parameters.put('pixelSpacingInDegree', 0.000222222222222) # Not functional    
target = GPF.createProduct('SARSim-Terrain-Correction', parameters, source)

# Write
ProductIO.writeProduct(target, 'outfile.tif', 'GeoTIFF') # Error occurs here

Have you changed your memory settings in the snappy.ini?
Please see:

The NullPointerException could be a result of a memory issue.

I’ve encountered this issue before, so snappy.ini is already set to 16G. In this instance increasing memory further doesn’t appear to make a difference

Shouldn’t you try to 1st make it work in the GUI and/or graph before doing it with Snappy?

@mengdahl Fair point!

Here’s my graph:

test_chain.xml (7.7 KB)

…which results in the error:

Error: [Nodeld: SAR-Sim-Terrain-Correction Metadata attribute 'processed_slave' not found

I guess that the Select/Merge operators aren’t copying over the inputs needed by SARSim-Terrain-Correction, but I can’t figure out what these are, either the using graph or Snappy.

1 Like

I think I’ve got it figured. I don’t know exactly what the issue was, but a simplified processing chain and some parameter tweaking seems to be working for my test scenes.

In case anyone in future runs into this issue, here’s the now functioning graph (for ALOS-1 data):

test_chain_final.xml (7.3 KB)

Thanks for the prod in the right direction @mengdahl

1 Like

If that complex graph gives you poor performance , try breaking it up in pieces .