原文地址:  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. ubuntu下如何高速下载?

    答: 使用uget工具 1.安装uget sudo apt-get install uget -y 2.下载时在设置里指定最大连接数 笔者指定最大连接数为10,可以适当调整此值

  2. Session案例-用户登录场景

    package com.loaderman.demo; import java.io.IOException; import java.io.PrintWriter; import javax.ser ...

  3. The inherit, initial, and unset values

    The  inherit, initial, and unset keywords are special values you can give to any CSS property. Tests ...

  4. 五十五:WTForms表单验证之渲染模板

    此功能看似强大,实则鸡肋 from wtforms import Form, StringField, BooleanField, SelectFieldfrom wtforms.validators ...

  5. Rxjava2实战--第四章 Rxjava的线程操作

    Rxjava2实战--第四章 Rxjava的线程操作 1 调度器(Scheduler)种类 1.1 RxJava线程介绍 默认情况下, 1.2 Scheduler Sheduler 作用 single ...

  6. on namespace ceilometer.$cmd failed: Authentication failed. 问题处理方案

    on namespace ceilometer.$cmd failed: Authentication failed. UserNotFound: Could not find user ceilom ...

  7. 解决 Elasticsearch 超过 10000 条无法查询的问题

    解决 Elasticsearch 超过 10000 条无法查询的问题 问题描述 分页查询场景,当查询记录数超过 10000 条时,会报错. 使用 Kibana 的 Dev Tools 工具查询 从第 ...

  8. 自由度为n的卡方分布χ²(n)的期望等于n、方差等于2n的证明

    出自:http://blog.sina.com.cn/s/blog_4cb6ee6c0102xh17.html

  9. Python实现将不规范的英文名字首字母大写

    Python实现将不规范的英文名字首字母大写 这篇文章给大家主要介绍的是利用map()函数,把用户输入的不规范的英文名字,变为首字母大写,其他小写的规范名字.文中给出了三种解决方法,大家可以根据需要选 ...

  10. JavaScript高程第三版笔记-函数表达式

    1⃣️递归 阶乘函数: function factorial(num){ ){ ; } ); } } 改装一:(arguments.callee指向正在执行的函数的指针,实现解耦) function ...