Dear All,
I’m quietly newbie in snappy and I am trying to subset a S-1 image with Snappy . I have tried with different images, but i only I trained myself with error:
band.readPixels(0, 0, w, h, band_data)
RuntimeError: java.lang.RuntimeException: javax.imageio.IIOException: I/O error reading image metadata!
The source code as follows:
import sys
sys.path.append(’/home/dani-ifca/.snap/snap-python/’)
from snappy import ProductIO
from snappy import jpy
from snappy import GPF
from snappy import HashMap
import numpy as np
import matplotlib.pylab as plt
pathS1=’/home/dani-ifca/Escritorio/image sentinel/S1B_IW_GRDH_1SDV_20161111T061637_20161111T061702_002907_004EEF_B9BC.SAFE’
p = ProductIO.readProduct(pathS1)
width = p.getSceneRasterWidth()
height = p.getSceneRasterHeight()
name = p.getName()
band_names = p.getBandNames()
print(“Product name: %s. Size = %d x %d pixels” % (name, width, height))
print(“Bands: %s” % (list(band_names)))
x = 18727
y = 15438
width = 2872
height = 3459
HashMap = jpy.get_type(‘java.util.HashMap’)
GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis()
parameters = HashMap()
parameters.put(‘copyMetadata’, True)
parameters.put(‘region’, “%s,%s,%s,%s” % (x, y, width, height))
subset = GPF.createProduct(‘Subset’, parameters, p)
band = subset.getBand(‘Amplitude_VV’)
w = band.getRasterWidth()
h = band.getRasterHeight()
band_data = np.zeros(w * h, np.float32)
band.readPixels(0, 0, w, h, band_data)
Thank you in advance.