4

Following the GeoAlchemy tutorial, I have created an object with the following geom field:

Base = declarative_base()

class House(Base):
....
    geom = Column(Geometry('POINT', 4326))

When I query the object from the database, with:

house = database.db_session.query(House).filter_by(whatever).first()

I get a House instance with a geom column:

print house.geom
01e90300005cb2a79e3d6341400e396508a20a40400000000000000000

print type(question.geom)
<class 'geoalchemy2.elements.WKBElement'>

How do I query the WKBElement for its latitude and longitude? I did not find the answer in the class documentation, neither in its source.

Adam Matan
  • 128,757
  • 147
  • 397
  • 562

1 Answers1

0

in postgres you can look up long lat information of a wkb element like so:

  ST_X('01e90300005cb2a79e3d6341400e396508a20a40400000000000000000') as long,
  ST_Y('01e90300005cb2a79e3d6341400e396508a20a40400000000000000000') as lat
B-C B.
  • 183
  • 1
  • 5