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
3
votes
2 answers

Correct json format to save into geoalchemy2 Geometry field

I have a json of this format: { "type":"Feature", "properties":{}, "geometry":{ "type":"Point", "coordinates":[6.74285888671875,-3.6778915094650726] } } And a flask-geoalchemy2 defined field like this:- from…
Calvin Cheng
  • 35,640
  • 39
  • 116
  • 167
2
votes
0 answers

Reference same table from outer query in subquery sqlalchemy + geoalchemy2 ORM

I am trying to convert a query to an equal orm statement in sqlalchemy and geoalchemy2. I am struggeling how to get the reference for p1.geom into the subquery in the not exists clause. SELECT p1.geom FROM polygons as p1 WHERE p1.column1 =…
Heyjuke58
  • 21
  • 2
2
votes
1 answer

Geoalchemy2 Find a location within certain distance within given coordinate

I have a flask app that first fetches a location from Google Maps API and am trying to find the location that is closer to it within 1500 meters that is in the database I have. Here is my places model. class Places(db.Model): uuid =…
2
votes
2 answers

Is there an example SQLAlchemy UserDefinedType for Microsoft SQL Server Geography/Geometry Types?

How can I create a SQLAlchemy UserDefinedType that will allow me to insert into a Geography data type on SQL Server? I am using Python 3.6 and Pandas to_sql to write into a SQL Server table that will have a column with a geography data type. I am…
Rick
  • 347
  • 4
  • 16
2
votes
1 answer

Storing a WKBElement in PostGis using Geoalchemy2 results in an incorrect longitude

I'm working on an application which needs to be able to store a point in a PostGis database. I'm using GeoAlchemy, and it seems to store an incorrect longitude. I have this code to process a request to add an Event with Point location…
Todorus
  • 95
  • 6
2
votes
2 answers

spatialite backend for geoalchemy2 in Python

I'm trying to SQLITE/spatialite with geoalchemy2. It seems to be possible according that link. My problem comes I think from the custom engine. What I have so far: from flask_sqlalchemy import SQLAlchemy from geoalchemy2 import Geometry #and other…
Laurent R
  • 783
  • 1
  • 6
  • 25
2
votes
0 answers

Flask uploading shapefiles into postgis

I am trying to upload a shapefile into PostGIS. I am using Flask and have gotten the files from the user (.shp, .shx, .dbf and .prj) and saved them to temporary files before using PYSHP python library to access the shapes collection. r =…
mjb
  • 65
  • 7
2
votes
1 answer

How to use an existing PostGIS database in a Flask web app

I'm building a web app using Flask and a PostGIS database I already created. I'm struggling to get Flask-SQLAlchemy to accept the geom column of my existing database. I declare db in an init.py file: from flask import Flask, request,…
2
votes
1 answer

Geometry('POINT') column being returned as str object

I have an sqlalchemy model object which has the following column: gps = Column(Geometry('POINT')) I have implemented a to_dict function in the model class, for which I need to deconstruct the gps object to give me lat and long. This successfully…
wanderingProgrammer
  • 191
  • 1
  • 3
  • 19
2
votes
2 answers

Geoalchemy2 & ST_Within - type mismatch between point and polygon?

I want to run a query which returns every point which falls within a rectangle, where the points and the rectangle are based on real-world longitudes and latitudes. This is the query which fails: results =…
Andrew Mackie
  • 344
  • 3
  • 13
2
votes
1 answer

type modifier is not allowed for type "geometry" when updating DB with postgis via geoalchemy2 & alembic

My alembic update script for adding a new postgis geometry point looks like this: from alembic import op import sqlalchemy as sa import geoalchemy2 as ga def upgrade(): op.add_column('stuff', sa.Column('my_location', ga.Geometry('POINT',…
user1561108
  • 2,666
  • 9
  • 44
  • 69
1
vote
1 answer

Use PostGIS geometry types in SQLModel

Is it possible to use PostGIS geometry types in models created in SQLModel? If yes, how can it be done?
Charalamm
  • 1,547
  • 1
  • 11
  • 27
1
vote
0 answers

WKBReadingError with PostGIS + Shapely with PostGIS Geography column (Unknown WKB type 233)

I have a table called signs with 2 fields. Notice one is geometry and one is geography class Sign(AbstractMapObj, Base): __tablename__ = "signs" location = Column(Geometry('POINTZ', dimension=3), nullable=False) geometry_lla =…
Jakobovski
  • 3,203
  • 1
  • 31
  • 38
1
vote
0 answers

Get the nearby place to certain coordinates from database

I created this function: def get_nearby_aqi_node(lat, lng): distance_in_meters = 1500 geo_wkb = func.Geometry(func.ST_GeographyFromText( 'POINT({} {})'.format(lng, lat))) point = db.session.query(Hotel.hotel_name, …
1
vote
1 answer

How to insert a Geometry with geoalchemy2 and postgresql

I'm trying to insert a geometry data into database but it's not working. I created a model class for Geometry, but i don't now if it's right. Geometry class: from datetime import datetime from sqlalchemy import and_ from sqlalchemy import…