C++ 如何将 Lat ,long 转换为 XY 坐标系(例如 UTM),然后将其映射到我的图像的像素空间
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6172355/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to Convert Lat ,long to an XY coordinate system (e.g. UTM) and then map this to pixel space of my Image
提问by Verve Innovation
I have a very small area map , which I downloaded from Openstreet map(PNG) and also its OSM(.osm) file which contains its Lat ,long.
我有一个非常小的区域地图,我从 Openstreet 地图(PNG)下载了它,还有它的 OSM(.osm)文件,其中包含它的经纬度。
Now I want to convert Lat ,long to an XY coordinate system (e.g. UTM) and then map this to pixel space of my Image which is of size (600 x 800 ). I know its a two way process ,like to know how to do this . Thank you
现在我想将 Lat ,long 转换为 XY 坐标系(例如 UTM),然后将其映射到我的 Image 大小(600 x 800)的像素空间。我知道它的双向过程,想知道如何做到这一点。谢谢
采纳答案by Brian Webster
GPS Coordinates to Pixels
GPS 坐标到像素
- Assuming this map does not cross prime meridian
- Assuming pixel 0,0 is upper left, and pixel 600,800 is lower right.
Assuming map is Northern Hemisphere Only (no part of map is southern hemisphere)
- Determine the left-most longitude in your 800x600 image (X)
- Determine the east-most longitude in your 800x600 image (Y)
- Determine Longitude-Diff (Z = Y - X)
- Determine north-most latitude in your 800x600 image (A)
- Determine south-most latitude in your 800x600 image (B)
- Determine Longitude-Diff (C = A - B)
- 假设这张地图不跨越本初子午线
- 假设像素 0,0 在左上角,像素 600,800 在右下角。
假设地图仅是北半球(地图的任何部分都不是南半球)
- 确定 800x600 图像中最左侧的经度 (X)
- 确定 800x600 图像中的最东经度 (Y)
- 确定经度差 (Z = Y - X)
- 确定 800x600 图像中最北端的纬度 (A)
- 确定 800x600 图像中最南端的纬度 (B)
- 确定经度差 (C = A - B)
Given a Latitude and Longitude, to determine which pixel they clicked on:
给定纬度和经度,以确定他们点击了哪个像素:
- J = Input Longitude
K = Input Latitude
Calculate X-pixel
XPixel = CInt(((Y - J) / CDbl(Z)) * 800)
Calculate Y-pixel
YPixel = CInt(((A - K) / CDbl(C)) * 600)
- J = 输入经度
K = 输入纬度
计算 X 像素
XPixel = CInt(((Y - J) / CDbl(Z)) * 800)
计算 Y 像素
YPixel = CInt(((A - K) / CDbl(C)) * 600)
UTM
UTM
Here is a cartographic librarythat should help with GPS to UTM conversions
这是一个制图库,应该有助于 GPS 到 UTM 的转换