So I am working with sentinel 1 GRD data, I want to preprocess an image and write it, the problem is that if I rename the only band in the product to something else (e.g. Sigma0_VV ----> DESCENDING_Sigma0_VV), the ProductIO.writeProduct function returns: RuntimeError: org.esa.snap.core.gpf.OperatorException: java.lang.NullPointerException
If I dont rename the band it writes the product with no problem
indent preformatted text by 4 spaces
pol = 'VV'
for folder in os.listdir(in_path):
# ids
gc.enable()
fid = in_path + folder + "//"
timestamp = folder.split("_")[4]
date = timestamp[:8]
#Read_file
print('input file: {}'.format(fid))
sentinel_1 = ProductIO.readProduct(fid + "//manifest.safe")
PASS = sentinel_1.getMetadataRoot().getElement('Abstracted_Metadata').getAttributeString('PASS')
#Apply orbit file
print('apply orbit file...')
orbit = apply_orbit_file(sentinel_1)
print('done')
del sentinel_1
# Radiometric calibration
print('radiometric calibration file...')
calibration = radiometric_calibration(orbit, pol)
print('done')
# Doppler terrain correction with SRTM3 DEM
print('doppler terrain correction with SRTM3 DEM...')
terr_corrected = terrain_correction(calibration, pol)
print('done')
del calibration
print('Old band names:')
for i in terr_corrected.getBandNames():
print(i)
print('Band rename...')
for i in terr_corrected.getBandNames():
terr_corrected.getBand(i).setName('{}_Sigma0_{}'.format(PASS, pol))
print('new band names:')
for i in terr_corrected.getBandNames():
print(i)
# Write a TIF file with a meaningful name
print('writing to: {}.tiff'.format(out_path + timestamp + '_' + PASS + '_' + pol))
ProductIO.writeProduct(terr_corrected, out_path + timestamp + '_' + PASS + '_' + pol, 'GeoTIFF-BigTIFF')
print('done!!')