标签:读取 strong class int process document group driver agg
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.
读取矢量shp案例:
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 包
https://www.osgeo.org/projects/gdal/ 官网
https://gdal.org/api/python_gotchas.html python
标签:读取 strong class int process document group driver agg
原文地址:https://www.cnblogs.com/icydengyw/p/12443310.html