Converting pixel position to geographical coordinates (lat, long) for Sentinel (S1 and S2) images?


#1

Hi,

is it possible to convert any pixel (or a set of pixels or a sub-region of an image) in a Sentinel image obtained via the Python API (https://github.com/sentinel-hub/sentinelhub-py) as described for example in this issue (for another API)?: https://stackoverflow.com/questions/51046217/converting-pixel-position-to-geographical-coordinates-lat-long-for-a-sentinel

Thanks
s.


#2

There are some functions in sentinelhub.geo_utils that can help you with that. However the first step is to download georeferenced tiff image in one of the UTM CRS. (That is because in UTM CRS pixels of the image are aligned with the CRS grid.)

Then you have to read the transform of the image. That can be done e.g. with GDAL library. In Python:

from osgeo import gdal, osr

dataset = gdal.Open(filename, gdal.GA_ReadOnly)
transform = dataset.GetProjection()

Then you can use tools from sentinelhub.

from sentinelhub import pixel_to_utm

east, north = pixel_to_utm(row, column, transform)  # returns pixel coordinates in image's UTM zone

Function sentinelhub.transform_point can help you further transform coordinates.