python - 将 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
解决方案
使用下面的自定义函数,我们可以轻松地将图像内的任何点转换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)
推荐阅读
- javascript - Three.js 使用正交相机将 2D 映射到 3D
- windows - Windows Powershell 只显示蓝屏;无法输入powershell
- javascript - 如何将时间戳字符串转换为日期?
- android - Retrofit + AWS S3 - 上传多个图像的预签名 URL,我应该使用带有 PUT 请求的循环吗?
- android - 未显示启动计费流程
- php - 如何在 Codeigniter 中无条件连接 100 个或更多表
- machine-learning - Google Cloud AutoML 中的身份验证问题
- python-3.x - 这是一个数独求解程序。我遇到了递归错误。我导入了 sys 模块并将递归限制设置为 1500,但仍然显示错误
- javascript - Javascript 非直观行为
- swift - 在 Web 服务响应后填充表视图