问题描述
如何从Sentinel-1合成孔径雷达(SAR)卫星图像的x,y位置获取地理坐标?
How can i get the geographical coordinates from x,y position in a Sentinel-1 Synthetic Aperture Radar (SAR) satellite image?
例如,我可以将下载的图像信息sg
设置为
For example, I can access a downloaded image info sg
as
from snappy import ProductIO
from snappy import PixelPos
path='path_name'
product = ProductIO.readProduct(path)
sg = product.getSceneGeoCoding()
但是我怎么能使用sg中获得所需点(x,y)的纬度和经度. com/senbox-org/snap-engine/tree/master/snap-python/src/main/resources"rel =" nofollow noreferrer> ESA在Python中的快照引擎?
But how can I get latitude and longitude for a desired point (x, y) in sg
using ESA's snap engine within Python?
推荐答案
使用下面的自定义函数,我们可以轻松地将图像sg
中的任何点转换为其坐标(纬度,经度):
Using the custom function below, we can easily convert any point inside our image sg
to its coordinates (latitude,longitude):
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:由于各种快照版本更新,上述功能可能无法正常工作.以下功能在大多数情况下都可以正常工作.
UPD:Because of various snap version updates, function above may not be working properly. Function below should work most of the times.
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)的坐标为
E.g. for the given sg
product, we can get coordinates of pixel (x=12000, y=2000) as
latitude, longitude = LatLon_from_XY(sg, 12000, 2000)
这篇关于将Sentinel-1 SAR图像的像素位置转换为地理坐标(纬度,经度)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!