geoalchemy

How to convert SDO_GEOMTRY in GeoJSON

青春壹個敷衍的年華 提交于 2019-12-12 05:38:50
问题 I work with sqlalchemy and geoalchemy and will convert my results in geojson. With the normal way like this : print json.dumps([dict(r) for r in connection.execute(query)]) it is not possible because cx_Oracle.Objets not serializable! I can have access through the separate attributes like this one: result = connection.execute(query) result2 = result.fetchone()[0] print result2.SDO_ORDINATES Here is my Programm: #!/usr/bin/env python # coding: utf8 #from __future__ import absolute_import,

SQLAlchemy Reflection Using Metaclass with Column Override

好久不见. 提交于 2019-12-11 09:18:14
问题 I have a set of dynamic database tables (Postgres 9.3 with PostGIS) that I am mapping using a python metaclass: cls = type(str(tablename), (db.Model,), {'__tablename__':tablename}) where, db.Model is the db object via flask-sqlalchemy and tablename is a bit of unicode. The cls is then added to an application wide dictionary current_app.class_references (using Flask's current_app) to avoid attempts to instantiate the class multiple times. Each table contains a geometry column, wkb_geometry

GeoAlchemy2 store point and query results

删除回忆录丶 提交于 2019-12-08 01:26:37
问题 The documentation on GeoAlchemy2 doesn't seem fully featured (as compared to the pervious version). I have a model: class AddressCode(Base): __tablename__ = 'address_codes' id = Column(Integer, primary_key=True) code = Column(Unicode(34)) geometry = Column(Geometry('POINT')) And I want to store lat/long data, which I tried to save in the above model, example "51.42553,-0.666085" Which gives me the error: "Parse error at position 9 within Geometry (the "," char") Anyone able to shed some light

GeoAlchemy2 store point and query results

假装没事ソ 提交于 2019-12-06 09:20:07
The documentation on GeoAlchemy2 doesn't seem fully featured (as compared to the pervious version). I have a model: class AddressCode(Base): __tablename__ = 'address_codes' id = Column(Integer, primary_key=True) code = Column(Unicode(34)) geometry = Column(Geometry('POINT')) And I want to store lat/long data, which I tried to save in the above model, example "51.42553,-0.666085" Which gives me the error: "Parse error at position 9 within Geometry (the "," char") Anyone able to shed some light on where I am going wrong here? Also on the subject, how would I peform a query to say.. Show nearest