Questions tagged [geoalchemy-2]
GeoAlchemy 2 provides extensions to SQLAlchemy to work with spatial databases. GeoAlchemy 2 focuses on PostGIS. PostGIS 1.5 and PostGIS 2 are supported. Dialects other than PostgreSQL/PostGIS are not supported, and if GeoAlchemy is referenced in a question, the [geoalchemy] tag should be used in preference.
23 questions
0
votes
1
answer
72
views
How to install GeoAlchemy2 on qgis 3.28.15 and use its libraries on qgis console?
I have installed GeoAlchemy2 and SqlAlchemy by using the osgeo command, but I am still not able to import the related libraries on the qgis console.
from geoalchemy2 import *
2
votes
1
answer
835
views
GeoPandas gdf.to_postgis: AttributeError: 'Cursor' object has no attribute 'copy_expert'
I'm facing the following error with GeoPandas 0.12.2 when trying to write a very simple GeoDataFrame containing simple points into an existing PostGIS database:
import geopandas as gpd
from sqlalchemy ...
0
votes
0
answers
156
views
geoalchemy2, WKT on local env, EWKT in production
I am working with an REST API for geospatial data using flask. When working on it locally everything has been fine. I am posting WKT data to the local server to create new objects. But if I send WKT ...
1
vote
0
answers
62
views
How to retrieve database line that matches two different sets of coordinates? I.E: pickup and delivery
When I run this query over my database, it returns every object with these coordinates.
coordinates being used in this first case: (41.8350653, -87.8630829)
SELECT
...
FROM (
SELECT
.....
1
vote
2
answers
3k
views
Setting CRS/SRID using the to_postgis function with GeoPandas?
So, I'm trying to update a PostGIS table after doing some reverse geocoding and other column manipulation I'm running into the find_srid() - could not find the corresponding SRID error.
Based on my ...
4
votes
1
answer
1k
views
How to correctly write the index as a primary key when exporting a GeoDataFrame to PostGIS
I'm trying to write a GeoDataFrame containing some POLYGON Z features directly to a PostGIS table which already has the right structure, especially a PolygonZ geometry column. This works fine:
G....
4
votes
1
answer
1k
views
Inserting geography data types with GeoPandas
I would like to insert a geodataframe containing point geometries in SRID 4326 to an existing table in PostGIS+PostgreSQL. The issue is that I would like to retain the existing table structure, which ...
1
vote
0
answers
3k
views
Calculating distance between 2 Shapely Points in Meters
I am trying to calculate the distance (in meters) between 2 lon/lng points of type shapely.geometry.point.Point using Python and Shapely. These 2 points are returned from PostGIS by SQLAlchemy/...
2
votes
1
answer
2k
views
Change PostGIS Column from Geometry to Geography
I have a PostGIS table with a column of type Geometry(POINT) and SRID 0 that must be changed to the type Geography(POINT) as it will be used to store lat/lon values.
How can we make this alteration to ...
0
votes
1
answer
416
views
Best method for expanding Multi* geometries to their constituent objects [closed]
I have a SpatiaLite table with a geometry column containing a mix of multi and single geometries, e.g. (Multipolygon, Polygon) or (MultiLineString, LineString). The application that will be reading ...
1
vote
1
answer
237
views
ST_Union on Rasters in Geoalchemy2 using ORM
I am attempting to perform a union on two rasters I pick from my postgis database using GeoAlchemy2.
I have a Raster table defined:
from geoalchemy2 import Raster
from sqlalchemy.sql import func
Base ...
0
votes
1
answer
207
views
Linestring table (of MultiLinestrings) ST_Intersection
I'm moving from GeoPandas to PostGIS and GeoAlchemy.
I've a table full of multilinestring geometries (timezones from NaturalEarth.com) and I've a linestring which represents what will be the route of ...
2
votes
1
answer
2k
views
How to extract lat, long coordinates from Geography type column in dataframe using SQLAlchemy?
This is the SQL command that works perfectly.
SELECT lonlat,
ST_Y(lonlat::geometry) AS latitude,
ST_X(lonlat::geometry) AS longitude
This is the output of the SQL command.
lonlat ...
2
votes
0
answers
519
views
PostGIS ST_Distance_Sphere speed-up
I am trying to build a geocoding app on OSM data, that in regard to arbitrary location will return points within specified radius, as well as distances to the points.
I have the following table:
id ...
2
votes
1
answer
1k
views
Create table in one schema, update geometry_columns View in Public schema using GeoAlchemy2
Using the SQLAlchemy ORM with GeoAlchemy2, I can create the table in the public schema and the geometry_columns view gets updated as expected and the created table also includes a gist index on the ...
0
votes
0
answers
259
views
Perform Multiple Point in Polygon Queries PostGIS
I was wondering if there was a way to send one request to a PostgreSQL server with the PostGIS extension that contained multiple points, and then find the polygons that they are located in. For ...
0
votes
0
answers
1k
views
GeoAlchemy2: Cannot insert row because Function st_geomfromewkt(unknown) "does not exist"
i've been stuck on this problem for quite a while now and I can't figure out what could be the issue here.
I have a Postgres DB with postgis extension installed
CREATE EXTENSION IF NOT EXISTS ...
2
votes
1
answer
960
views
st_asMVT in geoalchemy2
I am new to geoalchemy/gis domain. I am looking to establish a local map server using postgis, flask and geoalchemy2. I have imported osm data into postgis and able to see it using qgis software. How ...
2
votes
1
answer
1k
views
Incorrect distances/area using Python and Shapely
I have a PostGIS table holding cadastral (property) data stored in SRID 3857 (Web Mercator). In Python I want to calculate the length of polygon lines and the area in metres and sq metres respectively....
1
vote
1
answer
756
views
Geoalchemy2 && support for ST_MakeEnvelope
I have this working query:
SELECT *
FROM my_table
WHERE my_table.the_geom && ST_MakeEnvelope(-75.97464419082118,39.523869271308314,-72.18532985820512,41.552541030492364);
and this is my (...
6
votes
1
answer
1k
views
Geoalchemy: insert 3D elements in PostGIS database
I have shp files that I would like to insert into a PostGIS database. I'm planning to use Geoalchemy2 and geopandas to do so. However, my data have the geometry types LINESTRING Z and POINT Z. As I ...
1
vote
0
answers
1k
views
create dynamic geometry point from WKTElement geoalchemy2
I have a function
def get_centres(origin_lat, origin_long):
pt = WKTElement('POINT({0} {1})'.format(origin_long, origin_lat), srid=4326)
centres = Centres.query.with_entities(Centres,...
14
votes
1
answer
15k
views
Converting geoalchemy2.elements.WKBElement to WKT
I have a geoalchemy2.elements.WKBElement that comes from a query on a Postgres/PostGIS view. I want to convert this to WKT, or otherwise encode it so that it is (Geo)JSON serialisable. How can I ...