Skip to main content
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 ...
geozelot's user avatar
  • 31.5k
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(...
Bera's user avatar
  • 82k
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 ...
Frank Jimenez's user avatar
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( ...
swiss_knight's user avatar
  • 11.4k
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 ...
geozelot's user avatar
  • 31.5k
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....
user3367601's user avatar
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....
pegel's user avatar
  • 166
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(...
Bera's user avatar
  • 82k
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."&...
iwishiwasaneagle's user avatar
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 ...
robin loche's user avatar
  • 2,560
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....
M Dollinger's user avatar
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 ...
ahmadhanb's user avatar
  • 41.8k
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, ...
Pedro Cury's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible