使用 Python 更改图像投影
图像角点坐标已知:
- 左上角:(70.20315, 20.92749)
- 右上角:(70.20315, 31.45240) 左下角
- :(59.70571, 20.92749)
- 右下角:(59.70571, 31.45240)
(基本上是芬兰和一点点的地图 )瑞典/挪威/俄罗斯)
我找不到将图像投影更改为 Google 地图叠加图像的方法,最好使用 Python。
可以使用 pyproj 和 PIL,但我不知道该怎么做。我还找到了 GDAL,更具体地说 gdalwarp,但找不到以正确方式更改投影的选项。
Image corner coordinates are known:
- Top left: (70.20315, 20.92749)
- Top right: (70.20315, 31.45240)
- Bottom left: (59.70571, 20.92749)
- Bottom right: (59.70571, 31.45240)
(Basically map over Finland and a little bit of Sweden/Norway/Russia)
I couldn't find a way to change image projection to Google maps overlay image, preferably using Python.
It's possible to do that with pyproj and PIL, but I wasn't able to figure out how to do that. I also found GDAL, and more specifically gdalwarp, but couldn't find options for changing projection in a correct way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
(从 gis 答案复制粘贴)
大量的试验和错误表明了这一点无需指定源投影即可正常工作。仅使用 GDAL Python API 即可实现相同的效果。重现步骤:
向 TIF 添加控制点(当然,首先
convert mapimage.png mapimage.tif
):然后,GDAL python 绑定包括
gdal2tiles.py
,它会自动生成图块地图的右投影以及示例地图页面。根据记录,我并不绝对肯定的预测完全正确,但在该领域,它似乎至少足够好。
(Copy-paste from gis answer)
Extensive trial-and-error showed it worked fine without specifying source projection. Same can be achieved using only GDAL Python API. Steps to reproduce:
Adding control points to TIF (of course, first
convert mapimage.png mapimage.tif
):Then, GDAL python bindings include
gdal2tiles.py
, which autogenerates tiles on right projection for maps, and also sample map pages.For the record, I'm not absolutely positive projection is exactly correct, but over that area it seems to be at least good enough.