0
내가 Jupyter 노트북에 아래의 코드를 실행하려고하면이 오류를 얻을 :'NoneType'객체에는 속성이 없습니다 'ExportToWkt'
을'NoneType'개체가 어떤 속성이없는 'ExportToWkt'
무엇이 문제입니까?
geometry = feature.GetGeometryRef()
가 없음 기하학 없습니다 할당되어
shapefile = osgeo.ogr.Open("C:/Users/chavoshi/Anaconda3/Example Data/Remorquages/pointdata.shp")
layer = shapefile.GetLayer(0)
#First delete the existing contents of this table in case we want to run the code multiple times.
cursor.execute("DELETE FROM B_B")
for i in range(layer.GetFeatureCount()):
feature = layer.GetFeature(i)
lats_o = feature.GetField("latitude_o")
#print(lats_o)
lons_o = feature.GetField("longitude_")
#Get feature geometry
geometry = feature.GetGeometryRef()
#Convert geometry to WKT format
wkt = geometry.ExportToWkt()
#Insert data into database, converting WKT geometry to a PostGIS geography
cursor.execute("INSERT INTO B_B (lats, lons, outline) VALUES ({}, {}, ST_GeogFromText('{}'))".format(lats_o, lons_o, wkt))
connection.commit()