Questions tagged [geoalchemy2]

GeoAlchemy 2 is a Python toolkit for working with spatial databases. It is based on the gorgeous SQLAlchemy.

GeoAlchemy 2 is a Python toolkit for working with spatial databases. It is based on the gorgeous SQLAlchemy.

https://github.com/geoalchemy/geoalchemy2

62 questions
0
votes
1 answer

Return Marshmallow Raw data for Geoalchemy2

I have the following SQLAlchemy model. class LocationModel(db.Model, BaseModel): """ Location Model """ __tablename__ = 'location' geolocation = db.Column(ga.Geometry('POINT', dimension=2, srid=4326)) def __init__(self,…
cp-stack
  • 785
  • 3
  • 17
  • 40
0
votes
0 answers

JSON auto adding backslashes

I'm trying to pass a GeoJson response that comes from a function called db.session.query(func.ST_AsGeoJSON(self.geometry)).first(), using GeoAlchemy and PostGres. When printing,…
0
votes
1 answer

Flask-Admin GeoAlchemy2 example doesn't show a map

I'm trying to run this example about how to use Flask-Admin displaying maps: https://github.com/flask-admin/flask-admin/tree/master/examples/geo_alchemy. In README.rst, there's this instruction: You will notice that the maps are not rendered. To…
Mauro Assis
  • 375
  • 1
  • 5
  • 22
0
votes
2 answers

finding nearest locations in GeoAlchemy and PostGIS

I am trying to do a simple query where I find the nearest locations to a user (in my example, I am using airports). The database records look like this: id: 2249 city: Osaka country: Japan location_type_id: 16 geolocation:…
cp-stack
  • 785
  • 3
  • 17
  • 40
0
votes
1 answer

Return valid GeoJSON with Flask + GeoAlchemy2 app

Since few days I am wondering how to make my Flask app return valid GeoJSON, here is what I got so far: models.py class Building(base): __tablename__ = 'buildings' id = Column(Integer, primary_key=True) district = Column(Unicode) …
BreadFish
  • 85
  • 1
  • 8
0
votes
0 answers

Polygon Contains Point - With GeoAlchemy

I'm trying to query a PostGIS table using GeoAlchemy to return the row where the point lies inside. I've a point and I'm using the timezones shapefile from natural earth. I've tried the below but it just returns the query and not the row item. class…
Tom Shelley
  • 111
  • 2
  • 11
0
votes
1 answer

Flask Alembic migration error with geoalchemy2 - invalid geometry_type

I'm trying to implement Flask-Migrate to help manage migrations, but I get an error when trying to make the migration script: "geoalchemy2.exc.ArgumentError: invalid geometry_type 'POINTZ' for dimension 2". I have a Flask project and am using…
0
votes
1 answer

how is geoalchemy2.shape defined and imported?

I have geoalchemy2 on my machine. If I import geoalchemy2 and run geoalchemy2.shape, I got: AttributeError: module 'geoalchemy2' has no attribute 'shape'. But if I run geoalchemy2.shape.to_shape(), it can find the method... I am confused on the…
Quan Zhou
  • 307
  • 1
  • 12
0
votes
1 answer

How to get `geom` part from ST_Dump using SQLAlchemy?

I want to translate following SQL-query into the Python code using SQLAlchemy. SELECT (ST_Dump(ST_Linemerge(ST_Union(geog::geometry)))).geom FROM my_table GROUP BY some_foreign_key I had a partial success with from geoalchemy2 import Geometry from…
SS_Rebelious
  • 1,274
  • 2
  • 19
  • 35
0
votes
1 answer

Find all users x miles away in flask + geoalchemy with ORM

I have created the following SQL query to find all users within a mile and it seems to work fine: SELECT * FROM user WHERE ST_DWithin( user.location, ST_MakePoint(-2.242631, 53.480759)::geography, 1609) ); However I want to convert this…
John Mike
  • 1,895
  • 3
  • 17
  • 26
0
votes
1 answer

How can I use Geoalchemy2 to update spatial data (like point)?

I just write a small website to show some spatial data using flask and Geoalchemy2. Now I can insert some new spatial records (for example, points) into my postgresql database but having some troubles when I want to update them. my code is as…
韩双犬
  • 1
  • 1
0
votes
1 answer

ng-map Drawing Manager to GeoAlchemy

I am trying to allow users on my app to define a "territory" (as a polygon). Then others can query a point (lat and long), to determine whos territory that point falls in. I have determined from the docs for GeoAlchemy2, that this would likely be…
GMarsh
  • 2,401
  • 3
  • 13
  • 22
0
votes
2 answers

How to calculate ST_Union with GeoAlchemy2?

I have a many-to-many relationship, with instances of OsmAdminUnit (polygon geometries) grouped into OsmAdminAgg instances. The model definitions are essentially: class OsmAdminUnit(db.Model): __tablename__ = 'osm_admin' id =…
leak_my_brain
  • 43
  • 1
  • 8
0
votes
2 answers

CKAN server down after installing ckanext-plugin extension

I'm trying to install the CKAN ckanext-spatial plugin by following the step-by-step instructions listed below. http://docs.ckan.org/projects/ckanext-spatial/en/latest/install.html#ubuntu-12-04-postgresql-9-1-and-postgis-1-5 After installation and…
AtomEye
  • 81
  • 7
0
votes
1 answer

How to retrieve data from geoalchemy2 Query result?

Code snippet from dbinit import session from geoalchemy2 import Geometry, func result = session.query(func.ST_AsText('POINT(100 100)')) How to retrieve the data from this result object?
asitm9
  • 853
  • 4
  • 12
  • 21