Snappy_subset.py does not save all the input metadata data

Hi,

I am using snappy_subset.py to create a subset of sentintel 1 images. However, it does not save all the metadata from the imput datasets, loosing that under the Original_Product_Metadata, which has the calibration files needed to perform the radiometric calibration of the radar data.

Any help will be really appreciated.

what is the output format of your subset image?

BEAM-DIMAP format.

are you working with SLC or GRD data?

With GRD data

can you please share the script you use?

import os
import sys
import snappy
from snappy import ProductIO, WKTReader

SubsetOp = snappy.jpy.get_type(‘org.esa.snap.core.gpf.common.SubsetOp’)

if len(sys.argv) != 3:
print(“usage: s <file> <geometry-wkt>" sys.argv[0])
print(” s ./TEST.N1 \"POLYGON((15.786082 45.30223, 11.798364 46.118263, 10.878688 43.61961, 14.722727" "42.85818, 15.786082 45.30223))\"" sys.argv[0])
sys.exit(1)

file_path = os.getcwd()
file = file_path + ‘\’ + sys.argv[1]

filename=os.path.splitext(os.path.basename(file))[0]
print("filename: ", filename)

wkt = sys.argv[2]

geom = WKTReader().read(wkt)

print(“Reading…”)

product = ProductIO.readProduct(file)

op = SubsetOp()
op.setSourceProduct(product)
op.setGeoRegion(geom)

sub_product = op.getTargetProduct()

print(“Writing…”)

ProductIO.writeProduct(sub_product, ‘…/R03_Subset/’+filename+’_subset.dim’, ‘BEAM-DIMAP’)

print(“Done.”)

Hi Andreas,

Some of the symbols in the print function have been corrupted in the copy/paste. Nevertheless the script is in this link:

Thanks and regards.

let’s wait for @marpet then who created this script :slight_smile:

Hi palejandro,

Try adding

op.setCopyMetadata(True)

to the code.

I’ve updated the script in the repository too.

It works. Thank you very much.