得到WFS层遍历特征

得到WFS层遍历特征
发布日期: 2016-10-06 更新日期: 1970-01-01 编辑:yubiao 浏览次数: 3760

标签:
 import sys

try:
    from osgeo import ogr, osr, gdal
except:
    sys.exit('ERROR: cannot find GDAL/OGR modules')

wfs_drv = ogr.GetDriverByName('WFS')

# Speeds up querying WFS capabilities for services with alot of layers
gdal.SetConfigOption('OGR_WFS_LOAD_MULTIPLE_LAYER_DEFN', 'NO')

# Set config for paging. Works on WFS 2.0 services and WFS 1.0 and 1.1 with some other services.
gdal.SetConfigOption('OGR_WFS_PAGING_ALLOWED', 'YES')
gdal.SetConfigOption('OGR_WFS_PAGE_SIZE', '10000')

url = 'http://example-service.com/wfs'
wfs_ds = wfs_drv.Open('WFS:' + url)
if not wfs_ds:
    sys.exit('ERROR: can not open WFS datasource')

layer = wfs_ds.GetLayerByName("largelayer")
if not layer:
     sys.exit('ERROR: can not find layer in service')

# now do something interesting with the features
feat = layer.GetNextFeature()
while feat is not None:
    feat = layer.GetNextFeature()
    # do something more..
feat = None
说明:

这个配方查询WFS服务取特征从一个大的层。建立了GDAL的配置使用WFS分页是否支持。


Copyright © Since 2014. 开源地理空间基金会中文分会 吉ICP备05002032号

Powered by TorCMS

OSGeo 中国中心 邮件列表

问题讨论 : 要订阅或者退订列表,请点击 订阅

发言 : 请写信给: osgeo-china@lists.osgeo.org