原文地址:  https://blog.csdn.net/hanshuobest/article/details/77752279

  //经纬度转utm坐标
int convert_lonlat_utm(const new3s_PointXYZ &lon_lat_coord, new3s_PointXYZ &utm_coord)
{
OGRSpatialReference *RefSource = new OGRSpatialReference;
RefSource->SetWellKnownGeogCS("WGS84"); OGRSpatialReference *RefTarget = new OGRSpatialReference;
RefTarget = RefSource->CloneGeogCS();
int utmzone = lon_lat_coord.get_x() / 6 + 31;
RefTarget->SetProjCS("UTM(WGS84) in northern hemisphere.");
RefTarget->SetUTM(utmzone, TRUE);
OGRCoordinateTransformation *poTransform = OGRCreateCoordinateTransformation(RefSource, RefTarget); double tempX = lon_lat_coord.get_x();
double tempY = lon_lat_coord.get_y();
double tempZ = lon_lat_coord.get_z(); poTransform->Transform(1, &tempX, &tempY, &tempZ);
utm_coord.set_x(tempX);
utm_coord.set_y(tempY);
utm_coord.set_z(tempZ); return utmzone;
}

  

//utm转经纬度
void convert_utm_lonlat(const new3s_PointXYZ &utm_coord, const int &utmzone, new3s_PointXYZ &lon_lat_coord)
{
//建立投影坐标系到经纬度坐标系的转换
OGRSpatialReference *RefSource = new OGRSpatialReference;
RefSource->SetWellKnownGeogCS("WGS84");
RefSource->SetProjCS("UTM(WGS84) in northern hemisphere.");
RefSource->SetUTM(utmzone, TRUE);
OGRSpatialReference *RefTarget = new OGRSpatialReference;
RefTarget = RefSource->CloneGeogCS();
OGRCoordinateTransformation *poTranform = OGRCreateCoordinateTransformation(RefSource, RefTarget); OGRPoint *poPoint = new OGRPoint();
double tempx = utm_coord.get_x();
double tempy = utm_coord.get_y();
double tempz = utm_coord.get_z(); poTranform->Transform(1, &tempx, &tempy, NULL);
lon_lat_coord = new3s_PointXYZ(tempx, tempy, tempz);

  

转载: utm坐标和经纬度相互转换的更多相关文章

  1. ArcGIS Engine 下投影坐标和经纬度坐标的相互转换

    ArcGIS Engine 下投影坐标和经纬度坐标的相互转换 投影转经纬度 ); pPoint.Project(pSRF.CreateGeographicCoordinateSystem((int)e ...

  2. ArcEngine下投影坐标和经纬度坐标的相互转换

    jojojojo2002 原文 ArcEngine下投影坐标和经纬度坐标的相互转换 投影转经纬度 private IPoint PRJtoGCS( double x, double y) { IPoi ...

  3. WGS84坐标和UTM坐标的转换

    如题.做了一个Demo,主要是把最后面的参考资料1里面的脚本改成了C语言版本的. 代码: #ifndef __COORCONV_H__ #define __COORCONV_H__ #include ...

  4. [转载]WGS84坐标与Web墨卡托坐标互转

    //经纬度转Wev墨卡托 dvec3 CMathEngine::lonLat2WebMercator(dvec3 lonLat) { dvec3 mercator; ; +lonLat.y)*PI/) ...

  5. R实现地理位置与经纬度相互转换

    本实例要实现目标通过输入城市名或者地名,然后找出其经度纬度值,以及通过可视化展现其线路流向以及周边地图展示 address_list数据: 山西省太原市小店区亲贤北街77号 贵州省贵阳市云岩区书香门第 ...

  6. C# UTM坐标和WGS84坐标转换小工具

    工具根据:http://home.hiwaay.net/~taylorc/toolbox/geography/geoutm.html js代码改编 工具源码github:https://github. ...

  7. python坐标获取经纬度或经纬度获取坐标免费模块--geopy

    一.官方文档 https://github.com/geopy/geopy 二.模块安装 pip3 install geopy 三.简单实用 from geopy.geocoders import N ...

  8. 百度、高德、谷歌、火星、wgs84(2000)地图坐标相互转换的JS实现

    一.调用例子: <!DOCTYPE html> <html lang="en"> <head> <meta charset="U ...

  9. 使用ArcGIS实现WGS84经纬度坐标到北京54高斯投影坐标的转换

    [摘 要] 本文针对从事测绘工作者普遍遇到的坐标转换问题,简要介绍ArcGIS实现WGS84经纬度坐标到北京54高斯投影坐标转换原理和步骤. [关键词] ArcGIS 坐标转换 投影变换 1 坐标转换 ...

随机推荐

  1. RestAssured

    配置MAVEN <dependency> <groupId>io.rest-assured</groupId> <artifactId>rest-ass ...

  2. 判断List是否为空的问题

    今天公司安排给页面调试Bug,感觉公司人员写的判断判断List是否为空存在一定的问题,公司判断是list!=null这是完全不对的,这只会判断是否有list对象.如果为空,他也会执行if(list!= ...

  3. CMD命令行管道命令

    一.什么是管道命令 管道命令能够将一个命令的执行结果经过筛选,只保留我们需要的信息. 如 dir 命令会显示目录下所有文件夹和文件,可以使用管道命令| findstr "" 将di ...

  4. 没有安装zip引发的一系列安装

    安装一个php框架的时候提示不能在线解压缩 通过phpinfo查看没有加载zip扩展,安装开始. 先安装了一次发现不能make,,,什么情况!!! 提示这个错误,好吧解决.make: *** No t ...

  5. Android版本之间的区别

    不同版本SDK适配要点 1,指定minSDKVersion与targetSDKVersion 2,运行时获取版本号 3,使用系统内置的主题,会随着版本的更换而自动适配 4,用android提供的注解 ...

  6. 理解MVC/MVP/MVVM的区别

    转载至[http://www.ruanyifeng.com/blog/2015/02/mvcmvp_mvvm.html] MVC 所有的通信都是单向的. M(Model)V(View)C(Contro ...

  7. Message 消息提示

    常用于主动操作后的反馈提示.与 Notification 的区别是后者更多用于系统级通知的被动提醒. 基础用法 从顶部出现,3 秒后自动消失. Message 在配置上与 Notification 非 ...

  8. [java][转]安装ADT的时候,提示“Cannot complete the install because one or more required items could not be

    今天在安装ADT的时候,提示“Cannot complete the install because one or more required items could not be found.  S ...

  9. php文件夹上传下载控件分享

    用过浏览器的开发人员都对大文件上传与下载比较困扰,之前遇到了一个php文件夹上传下载的问题,无奈之下自己开发了一套文件上传控件,在这里分享一下.希望能对你有所帮助. 以下是实例的部分脚本文件 这里我先 ...

  10. Node、Document关系的探究

    上图来自于<JavaScript权威指南(第六版)>P375 受到上图的启发,写了如下测试代码: var head = document.getElementsByTagName(&quo ...