geoalchemy2

Can't transform geometry to geojson

China☆狼群 提交于 2021-02-19 02:30:20
问题 My problem is this. I'm creating a model for some data. class Cables(Base): __tablename__ = 'cables' id = Column(Integer, nullable=False) route = Column(Geometry(geometry_type='LINESTRING', srid=4326), nullable=False) Now, I want to transform such a route to GeoJSON. Things I've tried @app.route("/api/cable/<int:id>", methods=['GET']) def get_cable(id): cable = session.query(Cables).filter(Cables.id == id).first() return str(geoalchemy2.functions.ST_AsGeoJSON(cable.route)) returns ST

How to get lng lat value from query results of geoalchemy2

落花浮王杯 提交于 2020-08-02 06:11:10
问题 For exammple, class Lake(Base): __tablename__ = 'lake' id = Column(Integer, primary_key=True) name = Column(String) geom = Column(Geometry('POLYGON')) point = Column(Geometry('Point')) lake = Lake(name='Orta', geom='POLYGON((3 0,6 0,6 3,3 3,3 0))', point="POINT(2 9)") query = session.query(Lake).filter(Lake.geom.ST_Contains('POINT(4 1)')) for lake in query: print lake.point it returned <WKBElement at 0x2720ed0; '010100000000000000000000400000000000002240'> I also tried to do lake.point.ST_X()

GeoAlchemy2: Get the lat, lon of a point

妖精的绣舞 提交于 2019-12-22 13:44:08
问题 Consider the following SQLAalchemy / GeoAlchemy2 ORM with a geometry field: from geoalchemy2 import Geometry, WKTElement class Item(Base): __tablename__ = 'item' id = Column(Integer, primary_key=True) ... geom = Column(Geometry(geometry_type='POINTZ', srid=4326)) When I update an item in the PostgreSQL shell: UPDATE item SET geom = st_geomFromText('POINT(2 3 0)', 4326) WHERE id = 5; Fetching the field: items = session.query(Item).\ filter(Item.id == 3) for item in items: print item.geom Gives

GeoAlchemy2: Get the lat, lon of a point

て烟熏妆下的殇ゞ 提交于 2019-12-06 05:41:14
Consider the following SQLAalchemy / GeoAlchemy2 ORM with a geometry field: from geoalchemy2 import Geometry, WKTElement class Item(Base): __tablename__ = 'item' id = Column(Integer, primary_key=True) ... geom = Column(Geometry(geometry_type='POINTZ', srid=4326)) When I update an item in the PostgreSQL shell: UPDATE item SET geom = st_geomFromText('POINT(2 3 0)', 4326) WHERE id = 5; Fetching the field: items = session.query(Item).\ filter(Item.id == 3) for item in items: print item.geom Gives: 01e9030000000000000000004000000000000008400000000000000000 This isn't a proper WKB - at least, it