首页 > 解决方案 > 将 Sentinel-1 SAR 图像的像素位置转换为地理坐标(纬度、经度)

问题描述

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

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

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

但是,在 Python中使用ESA 的 snap 引擎时,如何获得所需点 (x, y) 的纬度经度sg

标签: pythongeolocationsentinel1snap-pythonsentinel2

解决方案


使用下面的自定义函数,我们可以轻松地将图像内的任何点转换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

UPD:由于各种快照版本更新,上述功能可能无法正常工作。下面的功能应该在大多数情况下工作。

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)

推荐阅读