0
私はJupyterノートブックで以下のコードを実行しようとしたとき、私はこのエラーを取得:「NoneType」オブジェクトには属性がありません「ExportToWkt」
を「NoneType」オブジェクトが属性を持っていない「ExportToWkt」
問題は何ですか?ここで
は私のコードです:
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()