使用osgeo创建Vectory Layer时的AttributeError

时间:2016-02-04 16:03:22

标签: python gis

我正在使用此代码:

import osgeo.osr
spatialReference = osgeo.osr.SpatialReference()
spatialReference.SetWellKnownGeogCS('WGS84')

import osgeo.ogr
driver = osgeo.ogr.GetDriverByName("ESRI Shapefile") 
dstFile = driver.CreateDataSource("boundingBoxes.shp") 
dstLayer = dstFile.CreateLayer("layer", spatialReference)

它给出以下错误消息:

Traceback (most recent call last):
File "C:\Python27\saveborderinshapefile.py", line 8, in <module>    
dstLayer = dstFile.CreateLayer("layer", spatialReference)
AttributeError: 'NoneType' object has no attribute 'CreateLayer'

为什么此代码中dstFile设置为None

0 个答案:

没有答案