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

Geocoding addresses with geocoder gem and PostGIS database with RGeo

I am trying to use the geocoder gem for looking up addresses and coordinates. I want it to work together with my PostGIS spatial database and the RGeo gem, which uses POINT features instead of saving latitude and longitude values separately. So I…
12
votes
6 answers

Rails + PostGIS errors migrating database

I was following Daniel Azuma's talk on geospatial analysis with rails but I am having difficulty whenever I run rake db:migrate in the second project. The details of my setup are as follows: I am running Postgresql using Postgres.app which gives me…
tomciopp
  • 2,602
  • 2
  • 31
  • 60
12
votes
1 answer

st_intersects Vs st_overlaps

What is the difference between these two queries : select a.gid, sum(length(b.the_geom)) from polygons as a , roads as b where st_intersects(a.the_geom,b.the_geom) group by a.gid ; select a.gid, sum(length(b.the_geom)) from polygons…
Abhishek Sagar
  • 1,189
  • 4
  • 20
  • 44
11
votes
2 answers

MySQL Postgresql / PostGIS

I have lat/lon coordinates in a 400 million rows partitioned mysql table. The table grows @ 2000 records a minute and old data is flushed every few weeks. I am exploring ways to do spatial analysis of this data as it comes in. Most of the analysis…
Dojo
  • 5,374
  • 4
  • 49
  • 79
11
votes
2 answers

How to upgrade AWS RDS Postgres instance from 14 to 15 with postgis?

AWS added support for Postgres 15.2. Upgrading to this version with postgis extension enabled fails with this error message: The instance could not be upgraded because there are one or more databases with an older version of PostGIS extension or its…
Peter Kusza
  • 361
  • 3
  • 11
11
votes
2 answers

INSERT INTO and String Concatenation with Python

I have hit a major speed bump in inserting data in to my DB. You can see from the code below that I am simply building the SQL statement to pass in to the execute command. The values are correct and all is well there but the python interpreter seems…
aeupinhere
  • 2,883
  • 6
  • 31
  • 39
11
votes
1 answer

return size of table as MB not KB

Using Postgres to return the size of a table SELECT pg_size_pretty(pg_table_size('zlimitreacjed_1')); returns '1632 kb'....is there anyway to return this value as MB as opposed to kb's?
John
  • 3,965
  • 21
  • 77
  • 163
11
votes
1 answer

Postgres Postgis error: Library not loaded: /usr/local/lib/libspatialite.5.dylib

While browsing through a Postgres-Rails app in development, I came across a page error-ing out due to a PG error. Thinking my current Git branch's schema may have been out of sync with my database, I attempted to rake db:reset. This caused an error…
Krishna_Kulkarni
  • 459
  • 4
  • 12
11
votes
2 answers

Postgis 4326 geometry vs geography

After looking through web and Postgis in action book I still don't get 4326 geometry vs geography idea. As I understand geometry is a projection of a map to a surface, and geography is 3d representation (WGS86 Model). If both of them are 4326, what…
user505160
  • 1,176
  • 8
  • 25
  • 44
11
votes
1 answer

Using multiple databases within the same application

I am currently developing an application in node.js. I have a Postgres/PostGIS database to store geospatial information and render them as SVG. That works fine so far. On the other side I have a CouchDB database filled with data, from a previous…
Mathias Vonende
  • 1,400
  • 1
  • 18
  • 28
11
votes
1 answer

Unit of return value of ST_Distance

I need to calculate the distance between all buildings and all hospitals in a map imported from OSM. I use following query: SELECT building_id, hospital_id, ST_Distance(building_centroid, hospital_location) FROM ( select planet_osm_polygon.osm_id…
Glory to Russia
  • 17,289
  • 56
  • 182
  • 325
11
votes
3 answers

How can I create a polygon using fields in PostgreSQL?

I have 8 real values in a table that I'd like to combine into a polygon. I haven't been able to figure out how to create a polygon using these values though. I keep trying variations of SELECT polygon(lat1,lon1,lat2,lon2,lat3,lon3,lat4,lon4) FROM…
Dan Goldstein
  • 23,436
  • 10
  • 47
  • 51
11
votes
3 answers

My PostGIS database looks fine but GeoDjango thinks otherwise... why?

I'm trying to set up a GeoDjango app to test an earlier problem I was having. I've set up a postgresql database, created a new Django project and app, but when I try ./manage.py syncdb I get this: django.core.exceptions.ImproperlyConfigured: Cannot…
Phil Gyford
  • 13,432
  • 14
  • 81
  • 143
11
votes
2 answers

Find the nearest points along the linestring in specified distance limit and order

I have such problem and I would be nice If somebody can help me. I have points table with GIST index. Those points don't change in time. I would like to fetch points that are near some given linestring. Example: Imagine that linestring is the road…
Marcin Kapusta
  • 5,076
  • 3
  • 38
  • 55
10
votes
4 answers

Reading points from a Geography Polygon in a PostGIS database

My goal: To read the points from a Geography Polygon stored in my PostGIS database. The PostGIS manual has a great example of how to extract a Polygon from a database. PGgeometry geom = (PGgeometry)r.getObject(1); if (geom.getType() ==…
Steph
  • 2,135
  • 6
  • 31
  • 44