import sys try: from osgeo import ogr, osr, gdal except: sys.exit('ERROR: cannot find GDAL/OGR modules') server = 'proxy.example.com' port = 3128 # specify proxy server gdal.SetConfigOption('GDAL_HTTP_PROXY', server + ':' + port) # setup proxy authentication option for NTLM with no username or password so single sign-on works gdal.SetConfigOption('GDAL_PROXY_AUTH', 'NTLM') gdal.SetConfigOption('GDAL_HTTP_PROXYUSERPWD', ' : ') # now fetch a HTTP datasource and do something... ds = ogr.Open('http://featureserver/cities/.geojson') if not ds: sys.exit('ERROR: can not open GeoJSON datasource') lyr = ds.GetLayer('OGRGeoJSON') for feat in lyr: geom = feat.GetGeometryRef() print geom.ExportToWkt()
这个方法的设置选项的一个HTTP代理服务,使用NTLM身份验证(企业环境,使用Active Directory中的单点登录代理服务器支持的典型)。关于GDAL的HTTP代理服务器选项的更多信息可以在这里找到
关注公众号
获取免费资源