代码之家  ›  专栏  ›  技术社区  ›  Ioannis Nasios

哨兵-1sar图像像素位置到地理坐标(lat,long)的转换

  •  1
  • Ioannis Nasios  · 技术社区  · 8 年前

    我怎样才能得到 地理坐标 从哨兵1号合成孔径雷达(sar)卫星图像的x,y位置?

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

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

    但我怎么才能 纬度 经度 对于所需的点(x,y) SG公司 使用 ESA's snap engine within Python 是吗?

    1 回复  |  直到 8 年前
        1
  •  1
  •   Ioannis Nasios    7 年前

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