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案例:

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 

posted @ 2020-04-19 23:50  icydengyw  阅读(652)  评论(0编辑  收藏  举报