我一直在尝试GeoAlchemy2和I have some trouble with parsing its geom
field。to_shape()失败并出现ParseException
我试图use the built-in to_shape
function on a WKB element:
的例子如下:
lake = Session.query(Lake).get(1)
polygon = to_shape(lake.geom)
我用:
house = config.database.db_session.query(House)\
.filter_by(house_id=1).first()
print "geom:", house.geom
01e90300009aea561e53634140ffb86b0da20a40400000000000000000
from geoalchemy2 import shape
print "to_shape:", shape.to_shape(house.geom)
to_shape:
Traceback (most recent call last):
File "ranker_tester.py", line 40, in <module>
print "to_shape:", shape.to_shape(house.geom)
File ".../lib/python2.7/site-packages/GeoAlchemy2-0.2.4-py2.7.egg/geoalchemy2/shape.py", line 24, in to_shape
return shapely.wkb.loads(bytes(element.data))
File ".../lib/python2.7/site-packages/shapely/wkb.py", line 16, in loads
return reader.read(data)
File ".../lib/python2.7/site-packages/shapely/geos.py", line 361, in read
raise ReadingError("Could not create geometry because of errors "
shapely.geos.ReadingError: Could not create geometry because of errors while reading input.
任何想法,我怎么能解析这个GeoAlchemy2 GEOM场?数据库值是有效的。