6
votes
Accepted
Points which are beyond certain distance from multiple points
Geometric non-predicates are tricky, and your attempt in particular cannot benefit from a spatial index.
Consider this approach, which essentially inverts the filter and excludes matches, while being ...
5
votes
Accepted
From Geodataframe to PostGIS
You shouldnt need dtype={'geom': Geometry(geometry_type='GEOMETRY', srid= 4326)}.
Try without it and use .to_postgis:
import geopandas as gpd
from sqlalchemy import create_engine
gdf = gpd.read_file(...
5
votes
Accepted
Uploading a geodataframe with some missing geometries using 'to_postgis'
So thanks to the comments I was able to find an answer. The simplest way to create a 'geometry nonetype' is by creating an empty geometry. This is a representation of what I did:
from shapely.geometry ...
4
votes
Accepted
Change PostGIS Column from Geometry to Geography
Pure SQL
This statement should do the job:
ALTER TABLE your_table
ALTER COLUMN your_geometry_column
TYPE Geography(POINT, <yourFinalSRID_integer>)
USING ST_Transform(
ST_SetSRID(
...
4
votes
Accepted
Using ST_Distance with serialized Geography Points vs ST_MakePoint in query
Your column type is GEOGRAPHY; this type is the framework for geodetic measurements in PostGIS, and the returned unit corresponds to the axial dimensions of the reference spheroid (meter, as defined ...
3
votes
Points which are beyond certain distance from multiple points
Just adding to the solution by @geozelot for posterity. Anyone wanting to use the above SQL statement in Python / SQLAlchemy, here is the statement -
stmt = ~select([1]).where(func.ST_DWithin(points.c....
2
votes
Inserting GeoDataFrame into existing schema
geopandas.GeoDataFrame.to_postgis should not be creating a new schema. It will throw an error if the specified schema does not exist.
If you have created the schema, this should work just fine:
gdf....
2
votes
Accepted
Setting CRS/SRID using the to_postgis function with GeoPandas?
If you are interested in a workaround you can import your pandas dataframe and create a point table like this:
import pandas as pd
csvfile = r"C:\sample_data\data_1.csv"
df = pd.read_csv(...
2
votes
Accepted
How to map a single PostGIS function to multiple Spatialite functions with GeoAlchemy2
Question answered here https://github.com/geoalchemy/geoalchemy2/issues/377
def _compile_affine_sqlite(element, compiler, **kw):
"""Compile the element for the SQLite dialect."&...
2
votes
Accepted
Calculating the distance For each Row with respect to a Common Point
It looks like 'port.longitude' and 'fac.latitude' are correctly replaced in your f-string, but 'Warehouse.longitude' and 'Warehouse.latitude' are not and are left as string. The reason is you try to ...
2
votes
Points which are beyond certain distance from multiple points
Sufficient answers have been given, so let me explain the (or a part of the) problem with your query:
SELECT * FROM points, cities
creates a kartesian product from points and cities, with points....
1
vote
Installing GeoAlchemy2 and using its libraries on QGIS Python Console
The easiest way to install GeoAlchemy2 is by installing QGIS using OSGeo4W Network Installer:
After downloading, launch the installer
Select Advance install
Keep clicking Next until you reach the ...
1
vote
Geodataframe.to_postgis() with Flask and tracking SQLAlchemy Models
Figured that out using Geoalchemy2.
For those facing similar problem, this is what worked for me:
class AreaModel(db.Model):
__tablename__ = 'initial_areas'
id = db.Column(db.Integer, ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
sqlalchemy × 15postgis × 12
python × 9
geopandas × 7
geoalchemy-2 × 4
geoalchemy × 3
postgresql × 2
pyqgis × 1
shapefile × 1
geometry × 1
sql × 1
shapely × 1
spatialite × 1
pandas × 1
qgis-python-console × 1
geodataframe × 1
psycopg2 × 1
st-distance × 1