Dear All,
I just started using SNAP in python.
I tried the following code for calibrating a subset of a S-1 GRD product :
import os
import snappy
from snappy import ProductIO
from snappy import GPF
from snappy import jpy
from snappy import ProductUtils
GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis()
HashMap = jpy.get_type(‘java.util.HashMap’)
product_path="…\subset_0_of_S1A_IW_GRDH_1SSV_20141124T124847_20141124T124916_003424_003FF1_BDC2.dim"
image_name=“subset_0_of_S1A_IW_GRDH_1SSV_20141124T124847_20141124T124916_003424_003FF1_BDC2”
source_product = ProductIO.readProduct(product_path)
parameters = HashMap()
parameters.put(‘sourceBands’,‘Amplitude_VV’)
target_product = GPF.createProduct(‘Calibration’, parameters, source_product)
ProductIO.writeProduct(target_product, image_name+’_cal.dim’, ‘BEAM-DIMAP’)
I got this error message : RuntimeError: java.lang.OutOfMemoryError: GC overhead limit exceeded
Could somebody help me how to fix it? My laptop has 16G of RAM so it should be enough !
Fabiano
marpet
September 20, 2016, 12:53pm
#2
How much RAM is utilised can be configured in snappy.ini
See my post: Snappy error - ProductIO.writeProduct
Thank you very much !! it seems it is working better noe !!
I added the speckle filtering now… and despite I specify I want the ‘Median Filter’ it seems It is still using the default ‘Lee Sigma’…
What could I do wrong?
Here I attach my code
import os
import snappy
from snappy import ProductIO
from snappy import GPF
from snappy import jpy
from snappy import ProductUtils
GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis()
HashMap = jpy.get_type(‘java.util.HashMap’)
product_path="…\subset_0_of_S1A_IW_GRDH_1SSV_20141124T124847_20141124T124916_003424_003FF1_BDC2.dim"
image_name=“subset_0_of_S1A_IW_GRDH_1SSV_20141124T124847_20141124T124916_003424_003FF1_BDC2”
#Read source product
source_product = ProductIO.readProduct(product_path)
#Calibrate
parameters = HashMap()
parameters.put(‘sourceBands’,‘Amplitude_VV’)
target_product = GPF.createProduct(‘Calibration’, parameters, source_product)
#Speckle_Filtering
parameters = HashMap()
parameters.put(‘Pfilter’, ‘Median’)
parameters.put(‘PfiltersizeX’,5)
parameters.put(‘PfiltersizeY’,5)
target_product2 = GPF.createProduct(‘Speckle-Filter’, parameters, target_product)
#Write target product
ProductIO.writeProduct(target_product2, image_name+‘cal_spk .dim’, ‘BEAM-DIMAP’)
Thank you !
Fabiano
marpet
September 20, 2016, 2:08pm
#4
You need to remove the leading P from the parameter names.
Just:
parameters.put('filter', 'Median')
parameters.put('filtersizeX', 5)
parameters.put('filtersizeY', 5)
Shahbaz
December 21, 2017, 9:31am
#6
Hi Marpet and Fabianosnap, I trying to process Sentinel-1 data, its creating output but when i am trying to visualise my output in SNAP S1Tbx its showing blank. can you please guide me what is wrong with my code.
import snappy
from snappy import ProductIO
from snappy import jpy
import os, gc
from snappy import GPF
GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis()
HashMap = snappy.jpy.get_type(‘java.util.HashMap’)
GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis()
HashMap = jpy.get_type(‘java.util.HashMap’)
in_path = “/Satellite Data/SAR/S1” + “/”
for folder in os.listdir(in_path):
gc.enable()
out_path = “/Outputs/ImageOutput/”
output = out_path + “/”
timestamp = folder.split("_")[4]
date = timestamp[:8]
sentinel_1 = ProductIO.readProduct(in_path + folder + “/manifest.safe”)
print sentinel_1
pols = ['VH','VV']
for p in pols:
polarization = p
#Calibration:
parameters = HashMap()
parameters.put(‘outputSigmaBand’, True)
parameters.put(‘sourceBands’, ‘Intensity_’ + polarization)
parameters.put(‘selectedPolarisations’, polarization)
parameters.put(‘outputImageScaleInDb’, False)
calib = out_path + date + "_calibrate_" + polarization
target_0 = GPF.createProduct("Calibration", parameters, sentinel_1)
ProductIO.writeProduct(target_0, calib, 'GeoTIFF')
marpet
January 8, 2018, 4:20pm
#7
I’m not a SAR export. Maybe the configuration is not correct. Does it work if you use the same configuration in SNAP Desktop?
You could also try to export to BEAM-DIMAP instead of GeoTIFF.