GDAL学习
GDAL is a C++ translator library for more than 200 raster and vector geospatial data formats. It is released under an X/MIT style Open Source license by the Open Source Geospatial Foundation. As a library, it presents a single raster abstract data model and single vector abstract data model to the calling application for all supported formats. It also comes with a variety of useful command line utilities for data translation and processing. It offers an API for a variety of languages such as C, C++, Python, Perl, C# and Java
The related OGR library (OGR Simple Features Library), which is part of the GDAL source tree, provides a similar ability for simple features vector graphics data.
GDAL 是 Geospatial Data Abstraction Library 的缩写, 最开始的时候是一个用来处理栅格空间数据的类库,OGR 则是则是来处 理矢量数据的。 后来,这两个库合并成为合并成为一个,在下载安装的时候,都是使用GDAL 这一个名字。
由于 GDAL 对多种栅格数据格式都提供了支持,很多软件都使用它作为底层数据处理的库。 这其中比较有名的有:ArcGIS、Google Earth、OpenEV、GRASS GIS、OSSIM、Quantum GIS、MapServer、World Wind.
-
Core features
- Reading and writing of raster and vector geospatial formats 读写矢量和栅格地理空间数据
- Data format translation 数据格式转换
- Geospatial processing: subsetting, image warping, reprojection, mosaicing, tiling, DEM processing 地理空间数据处理:裁剪 投影 镶嵌 等
Implemented Standards
- Catalogue Service for the Web (CSW)
- Geographic JSON (GeoJSON)
- Georeferenced Tagged Image File Format (GeoTIFF)
- Geography Markup Language (GML)
- Keyhole Markup Language (KML)
- OpenStreetMap (OSM)
- Simple Features for SQL (SFSQL)
- Web Coverage Service (WCS)
- Web Feature Service (WFS)
- Well-Known Binary (WKB)
- Well-Known Text (WKT)
- Web Map Service (WMS)
- Web Map Tile Service (WMTS)
读取矢量shp案例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | import sys try : from osgeo import ogr, osr, gdal except : sys.exit( 'ERROR: cannot find GDAL/OGR modules' ) # try: # from osgeo import ogr # except: # import ogr driver = ogr.GetDriverByName( 'ESRI Shapefile' ) filename = 'D:/ArcGIS Data/Chinacity.shp' dataSource = driver. Open (filename, 0 ) if dataSource is None : print ( 'could not open' ) sys.exit( 1 ) print ( 'done' ) layer = dataSource.GetLayer( 0 ) n = layer.GetFeatureCount() print (n) extent = layer.GetExtent() print ( 'extent:' , extent) print ( 'ul:' , extent[ 0 ], extent[ 3 ]) print ( 'lr:' , extent[ 1 ], extent[ 2 ]) |
参考:
https://gdal.org/ GDAL documentation
https://www.osgeo.cn/pygis/gdal-gdalintro.html 中文教程
https://www.osgeo.cn/python_gdal_utah_tutorial/ch02.html?from=groupmessage
https://pcjericks.github.io/py-gdalogr-cookbook/ Python GDAL/OGR Cookbook!
https://pypi.org/project/GDAL/ python 包
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 记一次.NET内存居高不下排查解决与启示