我正在执行查询以通过python读取数据的几何形状。结果返回为元组。我需要将其转换为适合几何形状的形状。如何转换?
def read_geom(self,data_date,date):
cur = self.conn.cursor()
query = 'select ST_AsText("geom") from "%s_liveability_%s" ORDER BY "il kodu"' %(data_date,date)
cur.execute(query)
result = cur.fetchall()
return result
cur.close()
geom=P.read_geom(data_date,date[0])
from shapely.geometry import mapping, Polygon
import fiona
from shapely import wkb
# Here's an example Shapely geometry
for parcel in geom:
parcel.geom = wkb.loads(geom.Multipolygon, hex=True)
运行脚本
runfile('C:/Users/Bugra/Desktop/shpp.py', wdir='C:/Users/Bugra/Desktop')
runfile('C:/Users/Bugra/Desktop/shpp.py', wdir='C:/Users/Bugra/Desktop')
Traceback (most recent call last):
File "<ipython-input-48-fee537013116>", line 1, in <module>
runfile('C:/Users/Bugra/Desktop/shpp.py', wdir='C:/Users/Bugra/Desktop')
File "C:\Users\Bugra\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 786, in runfile
execfile(filename, namespace)
File "C:\Users\Bugra\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/Bugra/Desktop/shpp.py", line 24, in <module>
'geometry': mapping(poly),
File "C:\Users\Bugra\Anaconda3\lib\site-packages\shapely\geometry\geo.py", line 82, in mapping
return ob.__geo_interface__
AttributeError: 'tuple' object has no attribute '__geo_interface__'