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
13
votes
1 answer

Rails Postgis Upgrade Issues

I have installed Postgis and Postgresql through Homebrew on my Mac, and I wanted to upgrade my version of Postgis to 2.1.0-rc2. I unlinked my version of postgis, and then edited the postgis homebrew formula. After the new formula did not compile, I…
tomciopp
  • 2,602
  • 2
  • 31
  • 60
13
votes
1 answer

PostGIS recursive intersection between polygons

I'm trying to perform a recursive intersection between all the Polygons in a spatial Table, and obtain the resulting (multi)pololygons and the information about every intersection for each of them. An image (not really in scale) to explain…
Eggplant
  • 1,903
  • 1
  • 14
  • 24
13
votes
2 answers

Convert a Normal Postgres Database to PostGis Database

I have a normal postgres database with lots of geo coded data. This is just present two columns as latitude and longitude. I want to convert this database to PostGIs database. Can anyone suggest me a way to convert the database i have? I don't want…
13
votes
2 answers

Data binning: irregular polygons to regular mesh

I have thousands of polygons stored in a table format (given their 4 corner coordinates) which represent small regions of the earth. In addition, each polygon has a data value. The file looks for example like this: lat1, lat2, lat3, lat4, lon1, …
HyperCube
  • 3,870
  • 9
  • 41
  • 53
13
votes
3 answers

Why is PostgreSQL so slow on Windows?

We had an applicationg running using MySql. We found MySql was not suitable for our app after we found that it didnt support some of the GIS capability that PostGIS has (note: mysql only supports minimum-bounding rectangle GIS search). So we changed…
sivabudh
  • 31,807
  • 63
  • 162
  • 228
13
votes
2 answers

SQL query for point-in-polygon using PostgreSQL

I have the following simple table: CREATE TABLE tbl_test ( id serial NOT NULL, poly polygon NOT NULL ) WITH (OIDS=FALSE); I then try to insert a row with a polygon: insert into tbl_test values(1, PolyFromText('POLYGON((0 0, 10 10, 10 0, 0…
Assaf Lavie
  • 73,079
  • 34
  • 148
  • 203
12
votes
2 answers

Using alias from JOIN statement in FROM

I'm trying to build a PostGIS query that uses an alias of the JOIN statement in the FROM statement, but that is not possible. Is there another way to do it? SELECT DISTINCT ST_Buffer( ST_Centroid(geom), ST_Area(geom)) FROM building AS b,…
megges
  • 570
  • 1
  • 3
  • 11
12
votes
2 answers

How do I add PostGIS to my PostgreSQL setup using pure docker-compose

We have been using the following docker-compose.yml to account for PostgreSQL (another other redacted) dependencies. version: '3.5' services: postgres132: image: postgres:13.2 restart: always environment: POSTGRES_PASSWORD:…
Ayush Gupta
  • 8,716
  • 8
  • 59
  • 92
12
votes
4 answers

Is it possible to connect an existing database with Strapi CMS?

I am trying to create an API using Strapi CMS. I have an existing PostgreSQL + postgis database and I would like to connect-use this database in a Strapi project. Do you know if it is possible to do something like this?
Elena Valari
  • 173
  • 2
  • 2
  • 11
12
votes
1 answer

Get latitude/longitude from PostGIS point

I have a PostGIS table with a geometry field of SRID 3857 data. I want to get the centroid of the geometry as lat/lon coordinates, but can't seem to convert the values correctly: SELECT…
Yarin
  • 173,523
  • 149
  • 402
  • 512
12
votes
3 answers

Postgresql: Can't access to file « $libdir/postgis-2.1 » no such file or directory

I guess this is a known issue but since I have used a script that removed my postgresql-9.4-postgis-2.1, I'm now unable to get rid of this SQL error under Debian. Can't access to file « $libdir/postgis-2.1 » no such file or directory I've done the…
AnomalySmith
  • 597
  • 2
  • 5
  • 16
12
votes
2 answers

Order grouped rows before aggregate function

I have a postgis table with point geometries. points table: id | uid | date | geom Points with the same uid are the same target. I'm trying to GROUP BY uid with the ST_MakeLine to create a complete target LineString. SELECT uid,…
Ilia Choly
  • 18,070
  • 14
  • 92
  • 160
12
votes
2 answers

How do i get a bounding polygon around points?

I have a table with thousands of addresses as points. Is there a function in postgis that will allow me to get a bounding polygon around these points and return it as a polygon? update I am looking for a more complex polygon than just a bounding…
ADAM
  • 3,903
  • 4
  • 29
  • 45
12
votes
1 answer

Missing libraries when upgrading to PostGIS 2.1 and PostgreSQL 9.3.1 using homebrew

In the process of upgrading my PostgreSQL from version 9.2.4 to 9.3.1 (via homebrew on OS X) I came across an odd problem. These are the steps I took so far PostgreSQL, PostGIS and required libraries installed (no errors) run initdb on the new…
poezn
  • 4,009
  • 4
  • 25
  • 27
12
votes
2 answers

Problems with $libdir on PostgreSQL

In short, my question is "why doesn't $libdir work on my PSQL installation." CREATE FUNCTION st_box2d_in(cstring) RETURNS box2d AS '$libdir/liblwgeom', 'BOX2DFLOAT4_in' LANGUAGE c IMMUTABLE STRICT; yields an error could not access file…
Joe Germuska
  • 1,638
  • 1
  • 18
  • 34