【发布时间】:2017-04-03 02:41:49
【问题描述】:
我开始了解 GIS 数据。我有兴趣使用 Python 查看这些数据。我目前正在学习 shapefile。我正在学习 osgeo/ogr。我遇到了GetLayer() 方法。现在我无法理解 shapefile 中的图层是什么。是否需要向图层添加特征?
当我尝试如下创建多个图层时:
shapeData = driver.CreateDataSource('customer_points.shp')
layer = shapeData.CreateLayer('customs', spatialReference, osgeo.ogr.wkbPoint)
layer = shapeData.CreateLayer('customs1', spatialReference, osgeo.ogr.wkbPoint)
我得到的是与 customer_points 对应的 shapefile,只有一层 --- GetLayer(0) 有效,但 GetLayer(1) 返回 None
我还得到了对应于customs1 的 shapefile
因此,我能够检索添加到 customs 的功能,而不是通过从第一个 shapefile 读取第二层,而是通过从第二个 shapefile 读取第一层
【问题讨论】:
-
您能否提供一些有关您在哪里找到
GetLayer()函数(哪个库、软件等)的背景信息? Shapefiles 本身没有图层,我想你有些困惑。我稍后会尝试解释,或者其他人可以。 -
查看OGRDataSource class 的文档,它说
OGRDataSource可能 由许多OGRLayer对象组成。另请参阅 Python osgeo.ogr.DataSource 文档。