zoukankan      html  css  js  c++  java
  • GIS:GDAL开发库

    一.GDAL安装

    从GDAL 2.0+版本升级到3.0+版本
    
    3.0+版本必须依赖PROJ库,而且PROJ库必须是6.0+版本
    PROJ库需要proj.db数据库支持空间参考,默认在proj.dll目录中,也可以通过OSRSetPROJSearchPaths()来设置目录

    二.GDAL使用

    从GDAL 2.版本升级到3.版本,使用接口发生了改变

    OGRSpatialReference类用于实现OpenGIS空间参考系统定义,目前已经支持本地坐标系 地理坐标系 投影坐标系 垂直坐标系 地心坐标系 复合坐标系
    OGRSpatialReference::IsProjected()
    OGRSpatialReference::IsGeographic()
    OGRSpatialReference::GetSemiMajor()
    OGRSpatialReference::GetSemiMinor()
    OGRSpatialReference::GetInvFlattening()
    OGRSpatialReference::GetAttrValue()
    OGRSpatialReference::GetProjParm()
    OGRSpatialReference::GetLinearUnits()

    OGRCoordinateTransform类使用PROJ.4库实现坐标转换
    OGRCoordinateTransform::Transform()
    //GDAL2.0+版本
    
    void TestLongLat2UTM()
    {
      OGRCoordinateTransformation* poCT = nullptr;
      double dfCenterLong = 104.49242396000000;
      double dfCenterLat = 26.311051110000001;
      int nZone = static_cast<int>(dfCenterLong / 6 + 31);
      int bNorth = dfCenterLat >= 0 ? TRUE : FALSE;
      
      OGRSpatialReference oWGS84;
      oWGS84.SetWellKnownGeogCS("WGS84");
    
      OGRSpatialReference oUtmSrs;
      oUtmSrs.SetWellKnownGeogCS("WGS84");
      oUtmSrs.SetUTM(nZone, bNorth);
    
      poCT = OGRCreateCoordinateTransformation(&oWGS84, &oUtmSrs);
    
      double dx = 104.28982973166080;
      double dy = 26.567797593704370;
      double dz = 1826.8254084027094;
      int bTransformSuccess;
      poCT->Transform(1, &dx, &dy, &dz, &bTransformSuccess);
    
      OGRCoordinateTransformation::DestoryCT(poCT);
    
    }
    //GDAL3.0+
    
    void TestLongLat2UTM()
    {
      OGRCoordinateTransformation* poCT = nullptr;
      double dfCenterLong = 104.49242396000000;
      double dfCenterLat = 26.311051110000001;
      int nZone = static_cast<int>(dfCenterLong / 6 + 31);
      int bNorth = dfCenterLat >= 0 ? TRUE : FALSE;
    
      OGRSpatialReference oWGS84;
      oWGS84.SetWellKnownGeogCS("WGS84");
      oWGS84.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);  //在新版GDAL中,这一行非常重要,必须出现才能运行
      
    OGRSpatialReference oUtmSrs;
    oUtmSrs.SetWellKnownGeogCS("WGS84");
    oUtmSrs.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);
    oUtmSrs.SetUTM(nZone, bNorth);

    poCT = OGRCreateCoordinateTransformation(&oWGS84, &oUtmSrs);

    double dx = 104.28982973166080;
    double dy = 26.567797593704370;
    double dz = 1826.8254084027094;
    int bTransformSuccess;
    poCT->Transform(1, &dx, &dy, &dz, &bTransformSuccess);

    OGRCoordinateTransformation::DestoryCT(poCT)
    }

    1.栅格

    2.矢量

    3.地理网络模型

    4.投影和空间参考系统(OSR-OGRSpatialReference)

    OGRSpatialReference类
    
    OGRCoordinateTransformation类

  • 相关阅读:
    magento设置快捷支付后,付款出现Unable to communicate with the PayPal gateway
    Magento安装插件失败出现503错误的解决方法
    magento安装插件后显示404error
    magento安装插件报connection string is empty
    mysql修改root密码
    thinkphp 3.2.3版本学习笔记
    那些年,被我蠢哭了的php代码小错误~~~
    PHP实现文件上传和下载(单文件上传、多文件上传、多个单文件上传)(面向对象、面向过程)
    php生成纯数字、字母数字、图片、纯汉字的随机数验证码
    php使用GD库实现图片水印和缩略图——封装成类
  • 原文地址:https://www.cnblogs.com/k5bg/p/15133280.html
Copyright © 2011-2022 走看看