目录
1. AttributeError: ‘NoneType’ object has no attribute ‘GetLayerByName’
原因: 路径问题,说明输入的文件的路径不对,需要重新检查一下问价的路径,如:
错误:
folder = r'E:\Google chrome\Download\gis with python\osgeopy data'
正确:
folder = r'E:\Google chrome\Download\gis with python\osgeopy data\California'
2. AttributeError: module ‘osgeo.osr’ has no attribute ‘SRS_WKT_WGS84’
GDAL升级到3.0之后API变化:SRS_WKT_WGS84宏定义被替换为 SRS_WKT_WGS84_LAT_LONG 。
3. ERROR 1: PROJ: proj_identify: Cannot find proj.db
1.看变量值那个路径中有没有 proj.db 这个文件:GDAL下载
2.设置环境变量:
4. TypeError: ‘Layer’ object is not an iterator
错误原因: 迭代器问题
源代码:
for tag_id in tag_ids:
print('Processing ' + tag_id)
# 限制点为当前的id
lyr.SetAttributeFilter(
"tag_id ='{}'".format(tag_id))
# 保存第一次结果和点
#row = lyr.GetNextFeature()
row = next(lyr)
previous_pt = row.geometry().Clone()
previous_time = row.GetField('timestamp')
修改:
for tag_id in tag_ids:
print('Processing ' + tag_id)
# 限制点为当前的id
lyr.SetAttributeFilter(
"tag_id ='{}'".format(tag_id))
# 保存第一次结果和点
row = lyr.GetNextFeature()
#row = next(lyr)
previous_pt = row.geometry().Clone()
previous_time = row.GetField('timestamp')
结果: