原文地址:  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. Python: sklearn库——数据预处理

    Python: sklearn库 —— 数据预处理 数据集转换之预处理数据:      将输入的数据转化成机器学习算法可以使用的数据.包含特征提取和标准化.      原因:数据集的标准化(服从均值为 ...

  2. cookie、session的联系和区别,多台web服务器如何共享session

    1.Cookie与Session的联系: cookie在客户端保存状态,session在服务器端保存状态.但是由于在服务器端保存状态的时候,在客户端也需要一个标识,所以session也可能要借助coo ...

  3. Android studio 项目支持JNI方法

    步骤: 1. build.gradle 配置如下,主要两项 ndk 和 sourceSets apply plugin: 'com.android.application' android { com ...

  4. Scope 'request' is not active for the current thread

    Unable to instantiate Action, getUserAction, defined for 'getUser' in namespace '/'Error creating be ...

  5. SAS数据挖掘实战篇【二】

    SAS数据挖掘实战篇[二] 从SAS数据挖掘实战篇[一]介绍完目前的数据挖掘基本概念之外,对整个数据挖掘的概念和应用有初步的认识和宏观的把握之后,我们来了解一下SAS数据挖掘实战篇[二]SAS工具的应 ...

  6. //C#中的访问数据符

    [在命名空间里面直接定义类型只能用internal  或 public ] [要被同个解决方案内 其他项目访问 ,加引用 导命名空间]. [类的默认修饰符是internal] 1.Private    ...

  7. 移动端1px 边框

    伪类+ transform .border_1px:before{ content: ''; position: absolute; top: 0; height: 1px; width: 100%; ...

  8. mpVue学习笔记整理

    第一章: mpVue(Vue in Mini Program) 1.1 简介 美团工程师推出的基于Vue.js封装的用于开发小程序的框架 融合了原生小程序和Vue.js的特点 可完全组件化开发 1.2 ...

  9. XML模块,面向对象思想与类的定义

    今日内容 XML模块,面向对象思想,类的定义 1.XML模块 xml是一种可扩展的标记语言格式如下 使用 <> 作为标签格式 <tag style: '' color:read '' ...

  10. java-循环变量定义问题

    第15行,这样就会报错.