I’m trying to get pixel position from a given Lat/Lon in snappy.
To do so I wrote this little function below:
def m_getPixelPos(source,lat,lon): from snappy import GeoPos,PixelPos import numpy as np if source.getSceneGeoCoding().canGetPixelPos() is not True: raise Exception('Can''t get Pixel Position from this source') else: pos = GeoPos(lat, lon) pixpos=source.getSceneGeoCoding().getPixelPos(pos,None) X = np.round(pixpos.getX()) Y = np.round(pixpos.getY()) return [X,Y]
If I apply the function to a geocoded S-1 image (without subsetting), using lat and lon from a WKT, I get different pixel position from what I see on SNAP GUI:
Lat and Lon are the following
In : lat Out: 41.473256216059198 In : lon Out: -5.6008912160591899
If I apply my
m_getPixelPos function I get:
In : m_getPixelPos(source,lat,lon) Out: [3879.0, 3726.0]
By looking at the SNAP GUI though, I see different pixel coordinates for those lat/lon:
Why I get this behaviour?
There is something I’m doing wrong on the PixelPos funtion or is some bug related to snappy?
If I apply the same function using a subsetted portion of the previous image as source, and lat and lon taken randomly from a pixel looking at snap gui, the result I obtain is correct so I guess I might be doing something wrong…but I can’t really find out what I’m missing.
Can anybody help me?
Thanks a lot!