Questions tagged [postgis]

Use this tag for PostGIS, which is a spatial database extension for PostgreSQL. Before using this tag, please consider whether your question might be a better fit for the Geographic Information Systems Stack Exchange site (e.g. if it's more about configuration or geodetic principles than about actual programming).

PostGIS is an open source extension for PostgreSQL that adds support for geographic objects. In effect, PostGIS "spatially enables" the PostgreSQL server, allowing it to be used for geographic information systems (GIS), much like ESRI's SDE or Oracle's Spatial extension. PostGIS follows the OpenGIS "Simple Features Specification for SQL" and has been certified as compliant with the "Types and Functions" profile.

PostGIS questions also on-topic for the Geographic Information Systems Stack Exchange site.

PostGIS has been developed by Refractions Research as a project in open source spatial database technology and is released under the GNU General Public License.

Features

  • Geometry types for points, linestrings, polygons, multipoints, multilinestrings, multipolygons and geometrycollections.
  • Spatial predicates for determining the interactions of geometries using the 3x3 Egenhofer matrix (provided by the GEOS software library).
  • Spatial operators for determining geospatial measurements like area, distance, length and perimeter.
  • Spatial operators for determining geospatial set operations, like union, difference, symmetric difference and buffers (provided by GEOS).
  • R-tree-over-GiST (Generalised Search Tree) spatial indexes for high speed spatial querying.
  • Index selectivity support, to provide high performance query plans for mixed spatial/non-spatial queries.

Tutorials:

4548 questions
16
votes
4 answers

Using PostGIS on Python 3

I'm using Python 3 and need to connect to postGre with postGIS extensions. I'm intending to use a psycopg2 driver. This PPyGIS is the only extension I found, but it works on python 2.7 not 3.3.0. Any one knows a solution working on 3.3.0 ?
Mille Bii
  • 185
  • 1
  • 2
  • 11
16
votes
2 answers

osm2pgsql: Function AddGeometryColumn doesn't exist

I want to import OSM file into my PostgreSQL database (Windows, Postgres Version 9.2) using the tool Osm2pgsql. When I run following command osm2pgsql.exe --create -d mydb artyom.xml -U myuser -W --style default.style I get the error SELECT…
Glory to Russia
  • 17,289
  • 56
  • 182
  • 325
16
votes
6 answers

missing libgeos_c.so on OSX

I am trying to install Postgis in order to use GeoDjango on OSX. For this, I first uninstalled postgres completely, then I installed everything following the GeoDjango documentation:…
mbrochh
  • 1,011
  • 1
  • 10
  • 21
16
votes
4 answers

PostgreSQL COPY FROM STDIN Expressions

I am attempting to use COPY FROM STDIN to import data into my table. One of the columns in my table is of type geometry. My command looks something like this... COPY "WeatherStations" ("Station_ID", "Station_Code", "Station_Name",…
elynnaie
  • 861
  • 2
  • 13
  • 28
15
votes
2 answers

How to convert polygon data into line segments using PostGIS

I have a polygon data table in PostgreSQL/PostGIS. Now I need to convert this Polygon data into its corresponding line segments. Can anybody tell me how to convert it using PostGIS queries. Thanks in Advance
gouse shaik
  • 151
  • 1
  • 1
  • 3
15
votes
2 answers

pg_dump does not write "CREATE EXTENSION postgis;"

We have dumped a database that uses the postgis extension using pg_dump. After manually creating the database on a different machine an attempt to load the dump into it using psql failed. It turned out the dump did not contain the necessary…
piokuc
  • 25,594
  • 11
  • 72
  • 102
15
votes
5 answers

Django Test -- Unable to drop and recreate test database

I am running Django 1.9, Postgres 9.5.1 on Mac OS X When I run /manage.py test --settings=myproj.settings.local I get : Creating test database for alias 'default'... Creating test database for alias 'userlocation'... Got an error creating the test…
fiacre
  • 1,150
  • 2
  • 9
  • 26
15
votes
5 answers

PostGIS Error - PG::InternalError: ERROR: could not load library

StandardError: An error has occurred, this and all later migrations canceled: PG::InternalError: ERROR: could not load library "/usr/local/Cellar/postgresql/9.4.5/lib/postgis-2.1.so": dlopen(/usr/local/Cellar/postgresql/9.4.5/lib/postgis-2.1.so,…
Harsha M V
  • 54,075
  • 125
  • 354
  • 529
15
votes
6 answers

Can I ask Postgresql to ignore errors within a transaction

I use Postgresql with the PostGIS extensions for ad-hoc spatial analysis. I generally construct and issue SQL queries by hand from within psql. I always wrap an analysis session within a transaction, so if I issue a destructive query I can roll it…
fmark
  • 57,259
  • 27
  • 100
  • 107
15
votes
1 answer

How do you uninstall Postgis?

I had PostGis installed on my machine, and somehow, some files got corrupted. I want to uninstall and reinstall PostGIS to hopefully get things working again, but I am not sure how to go about this. I am running Windows 8.1. I've tried searching for…
CodyBugstein
  • 21,984
  • 61
  • 207
  • 363
15
votes
3 answers

Determining approximate overlaps of a given polyline with a set of existing polylines

I have a set of polylines (numbering in the 100s of thousands, with each polyline having about 200-300 vertices). These represent routes on a map (all taken from Google Maps API, if that helps). The vertices are latitude/longitude coordinates. I am…
ARV
  • 6,287
  • 11
  • 31
  • 41
15
votes
3 answers

How do I fix missing PostGIS SRIDs in PostgreSQL?

I received the following error while running my Rspec test suite: PG::InternalError: ERROR: GetProj4StringSPI: Cannot find SRID (4326) in spatial_ref_sys I know that I enabled the PostGIS extension. How do I fix this?
barelyknown
  • 5,510
  • 3
  • 34
  • 46
15
votes
1 answer

Difference between multipolygon and polygon in PostGIS

What is the difference between point and multipoint ? linestring and multilinestring ? polygon and multipolygon ? In PostGIS What is the secret behind defining "Multi" shapes?
Ahlam
  • 317
  • 2
  • 3
  • 8
15
votes
5 answers

K-Nearest Neighbor Query in PostGIS

I am using the following Nearest Neighbor Query in PostGIS : SELECT g1.gid g2.gid FROM points as g1, polygons g2 WHERE g1.gid <> g2.gid ORDER BY g1.gid, ST_Distance(g1.the_geom,g2.the_geom) LIMIT k; Now, that I have created indexes on the_geom…
Abhishek Sagar
  • 1,189
  • 4
  • 20
  • 44
14
votes
1 answer

How to debug: Internal Error current transaction is aborted, commands ignored until end of transaction block

Hi Stackoverflow people, I do my first steps with GeoDjango and I am looking for better options to check faulty sql statements. So far, I simply wanted to safe a lng+lat point in my postgresql table. The model is defined with: geolocation =…
neurix
  • 4,126
  • 6
  • 46
  • 71