将 Sentinel-1 SAR 图像的像素位置转换为地理坐标(纬度、经度)

Converting pixel position to geographical coordinates (lat, long) for a Sentinel-1 SAR image

如何从 Sentinel-1 合成孔径雷达 (SAR) 卫星图像中的 x,y 位置获取 地理坐标

例如,我可以访问下载的图像信息 sg 作为

from snappy import ProductIO
from snappy import PixelPos 
path='path_name'
product = ProductIO.readProduct(path)
sg = product.getSceneGeoCoding()

但是如何使用 sg 中的所需点 (x, y) 获得 latitudelongitude ESA's snap engine within Python?

使用下面的自定义函数,我们可以轻松地将图像中的任何点 sg 转换为其坐标(纬度,经度):

def LatLon_from_XY(ProductSceneGeoCoding, x, y):
    #From x,y position in satellite image (SAR), get the Latitude and Longitude
    geopos = ProductSceneGeoCoding.getGeoPos(PixelPos(x, y), None)
    latitude = geopos.getLat()
    longitude = geopos.getLon()
    return latitude, longitude

更新: 由于各种快照版本更新,以上功能可能无法正常使用。下面的函数应该在大多数时候都有效。

def LatLon_from_XY(product, x, y):
    geoPosType = jpy.get_type('org.esa.snap.core.datamodel.GeoPos')
    geocoding = product.getSceneGeoCoding()
    geo_pos = geocoding.getGeoPos(snappy.PixelPos(x, y), geoPosType())
    if str(geo_pos.lat)=='nan':
        raise ValueError('x, y pixel coordinates not in this product')
    else:
        return geo_pos.lat, geo_pos.lon

例如对于给定的 sg 产品,我们可以得到像素坐标 (x=12000, y=2000) 作为

latitude, longitude = LatLon_from_XY(sg, 12000, 2000)