(I’m a snappy newbie. ;-))
I am trying to get a numpy array from a S3A_SY_2_VGP product.
It works for one line, or a rectangle starting in the top left corner, but it won’t work for a rectangle somewhere in the middle.
This is (part of) my code:
import numpy as np
from snappy import ProductIO
testfile=‘…/S3A_SY_2_VGP____20161101T061252_20161101T065709_20171209T023146_2657_010_248______LR1_R_NT_002.SEN3/xfdumanifest.xml’
RuntimeError: java.lang.IllegalArgumentException: The length of the given array is less than 40000
What are the correct arguments for readPixels() ? I interpreted it as (startcolumn, startrow, endcolumn, endrow, outputarray), but this seems incorrect.
Hi cartot,
I’ve started to use snappy some months ago and this is a problem I also got stuck into at the beginning.
I solved this and many other issues by looking at the snappy API reference page --> (http://step.esa.int/docs/v5.0/apidoc/engine/)
By the way, the arguments of readPixels are not as you interpreted but are readPixels(x,y,w,h,Array) with:
x: x offset of upper left corner
y: y offset of upper left corner
w: width of the desired data array
h: height of the desired data array
Array: the Output Array to be filled with data
So in your case, if you want to get pixels data inside a m x n rectangle, you have to set w = m and h = n inside readPixels (no matter which offset you select), thus: