我正在使用此代码:
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
?