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.