Hi there,
I have noted a difference in the output between raster bands and tie point grids, and was wondering how I could get around it. Using snappy, I do the following to extract a band to a raster:
# Open product
prod = ProductIO.readProduct(indir)
# Get width and height
w = prod.getSceneRasterWidth()
h = prod.getSceneRasterHeight()
# Initialise
array = np.zeros((w,h),dtype=np.float32) # Empty array
# Extract raster
currentband = prod.getBand(stringname)
bandraster = currentband.readPixels(0, 0, w, h, array)
With this method, bandraster is returned as an array. If I look at the SNAP Engine API the documentation for the Tie Point Grids says the following:
readPixels(int x, int y, int w, int h, float pixels, ProgressMonitor pm)
Retrieves an array of tie point data interpolated to the product with and height as float array.
However, using the same method as above, replacing the line:
currentband = prod.getBand(stringname)
with
currentband = prod.getTiePointGrid(stringname)
I don’t get an array anymore but instead a Java object:
In: tiepointraster
Out: [F(objectRef=0x9acec50)
In: tiepointraster.getClass()
Out: java.lang.Class(objectRef=0x9acec20)
How can I retrieve the Tie Point Grid as an array?
Cheers,