What is the right way to insert a Point to a PostGIS database using Python?
PostGIS – How to Insert a Point Using Python
postgispsycopg2python
Related Question
- [GIS] Parameterized insert query to PostGIS fails
- PostGIS – How to Insert a Point
- [GIS] Import shapefiles into PostGIS using Python with psycopg2
- [GIS] Insert points to PostGIS using a function
- [GIS] How to insert Polyhedralsurface into POSTGIS
- [GIS] Insert point into point column in postgres/postgis
- PostGIS – Inserting Waypoint with psycopg2 and ST_GeographyFromText
Best Answer
First, install the psycopg2 package, a Pythonic interface for PostgreSQL.
Then, use
ST_MakePoint
:ST_AsText
can be used to validate the values:Notes
(lat, lon)
is(y, x)
, not(x, y)
.(x, y, z)
at the end so thatpsycopg2
can handle the substitution.