--------------------------------------------------------------------------------------

#include <gdal_priv.h>
#include <ogrsf_frmts.h> GDALAllRegister();
OGRDataSource* poDS;
const char* pszDriverName = "ESRI Shapefile";
//
GDALDriverManager* pDriverManager = GetGDALDriverManager(); //new GDALDriverManager();
GDALDriver* pDriver = pDriverManager->GetDriverByName(pszDriverName);
if (pDriver == nullptr)
{
qDebug() << pszDriverName << " driver not available.";
return;
}
//
const char* filePathChar1 = "D:\\data";
OGRSFDriver* pSFDriver = static_cast<OGRSFDriver*>(pDriver);
OGRDataSource* pDataSource = pSFDriver->Open(filePathChar, FALSE); /*
OGRSFDriverRegistrar* pDriverRegistrar = OGRSFDriverRegistrar::GetRegistrar();
OGRSFDriver* pSFDriver = (OGRSFDriver*)pDriverRegistrar->GetDriverByName(pszDriverName);
OGRDataSource* pDataSource = pSFDriver->Open(filePathChar, FALSE);
*/ ------------------------------------------------------------------------------------------------ OGRLayer* pLayer = pDataSource->GetLayerByName(baseNameChar);
/*const char* geometryColumnName = pLayer->GetGeometryColumn();
int fieldIndex = pLayer->FindFieldIndex(geometryColumnName, TRUE);*/
// pEnvelopeDisplay
if (pLayerList.size() == 0) {
OGREnvelope* pEnvelope = new OGREnvelope();
pLayer->GetExtent(pEnvelope, TRUE);
double centerX = (pEnvelope->MinX + pEnvelope->MaxX) / 2;
double centerY = (pEnvelope->MinY + pEnvelope->MaxY) / 2;
double distanceX = pEnvelope->MaxX - pEnvelope->MinX;
double distanceY = pEnvelope->MaxY - pEnvelope->MinY;
//
}

--------------------------------------------------------------------------------------------------

GDAL读取Shapefile的更多相关文章

  1. GDAL读取Shp问题解决:Unable to open EPSG support file gcs.csv

    在GIS软件的开发中,经常用到开源库GDAL读取Shp数据,当shp数据中包含投影信息时,可能会遇到“Unable to open EPSG support file gcs.csv”错误提示,该错误 ...

  2. 使用C#版本GDAL读取复数图像

    GDAL的C#版本虽然在很多算法接口没有导出,但是在读写数据中的接口基本上都是完全导出了.使用ReadRaster和WriteRaster方法来进行读写,同时对这两个方法进行了重载,对于常用的数据类型 ...

  3. GDAL读取的坐标起点在像素左上角还是像素中心?

    目录 1. 问题 2. 结论 3. 例外 1. 问题 笔者在处理地理栅格数据的时候,总是会发生偏差半个像素的问题. 比如说通过ArcMap打开一张.tif,查看其地理信息:同时用记事本打开.tfw,比 ...

  4. ArcEngine读取ShapeFile时,出现乱码的解决方案

    ArcEngine读取ShapeFile时,如果用LicenseControl的话,字段中含有汉字时可以正常使用,当使用LicenseInitializer进行初始化时,读取含有汉字的字段时,就会出现 ...

  5. 结合C++和GDAL实现shapefile(shp)文件的读取

    工具:vs2012+GDAL 2.0 数据:中国省界SHP文件bou2_4p.shp   可点击下载 包含头文件: #include "ogrsf_frmts.h" 代码: int ...

  6. Java 使用GDAL 读写 shapefile

    读取shp文件,并把它转化为json import org.gdal.ogr.*; import org.gdal.ogr.Driver; import org.gdal.gdal.*; public ...

  7. 结合C++和GDAL实现shapefile(shp)文件的创建和写入

    工具:vs2012+GDAL 2.0 包含头文件: #include "ogrsf_frmts.h" int main() { const char *pszDriverName ...

  8. [GDAL]读取HDF格式的calipso数据

    探测地球云层分布的CloudSat和CALIPSO卫星 http://www.nasa.gov/mission_pages/calipso/main/index.html http://www.nas ...

  9. GDAL读取tiff文件/C++源码

    // gdal_geotiff.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include "gdal_priv.h&quo ...

随机推荐

  1. JS实现深浅拷贝

    1.实现浅拷贝 // 1. ...实现 let copy1 = {...{x:1}} // 2. Object.assign实现 let copy2 = Object.assign({}, {x:1} ...

  2. Python的包package的导入与被导入(包的类和方法的导入,__init__()怎么写)

    包package的导入与被导入: 参考一下: https://blog.csdn.net/guowujun321/article/details/80764468 1.文件目录: | |--  A/ ...

  3. sqlserver查询是否阻塞

    查询当前正在执行的语句 SELECT der.[session_id],der.[blocking_session_id], sp.lastwaittype,sp.hostname,sp.progra ...

  4. python生产者和消费者模式实现(二)多进程方式

    import timeimport randomfrom multiprocessing import Process, Queue # 生产者def producer(q, i): food = ' ...

  5. 使用Spring访问Mongodb的方法大全——Spring Data MongoDB

    1.概述 Spring Data MongoDB 是Spring框架访问mongodb的神器,借助它可以非常方便的读写mongo库.本文介绍使用Spring Data MongoDB来访问mongod ...

  6. 更改docker默认网段

    #本文档旨在说明创建docker时注意的事项:我们在局域网中使用Docker,最常遇到的一个困惑,就是有时候跨网段结果出现网络不通.原因是因为Docker默认生成的网关和我们的局域网网段有时候是冲突的 ...

  7. 有 va_arg宏 中数组下标-1 引发的思考 - C 语言中内存模型

    va_arg宏,是头文件 stdarg.h 中定义的,获取可变参数的当前参数. #define va_arg(list, mode) ((mode*)(list+=sizeof(mode)))[-1] ...

  8. Docker Harbor

    简介: Harbor是一个用于存储Docker镜像的企业级Registry服务:本章将介绍如何搭建Harbor Registry! Github官方安装文档: https://github.com/g ...

  9. openresty配置

    目录 环境 wsl安装 openresty安装 openssl版本问题 Lua模块安装 openresty使用 nginx常用命令 nginx.conf 配置 lua 的一些坑 OpenResty缓存 ...

  10. 7.2 Spark Streaming

    一.Spark Streaming设计 Spark Streaming可整合多种输入数据源,如Kafka.Flume.HDFS,甚至是普通的TCP套接字.经处理后的数据可存储至文件系统.数据库,或显示 ...