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

Generate population heatmap: Mapreduce?

I have a MySQL table containing (100 million) Lat/Lng coordinates of locations in America Number of people living within a square mile radius of that location Question: After generating and overlaying the heatmap on a Google maps or…
Nyxynyx
  • 61,411
  • 155
  • 482
  • 830
2
votes
1 answer

Problems combining (union) Multipolygons in geodjango

I'm using geodjango and postgis (1.x), What is the best way to combine (union) a list of multipolygons. in what i assume is rather inefficient i'm looping trough like this combined = multipolygon for item in items: combined =…
kennethj
  • 139
  • 3
  • 7
2
votes
1 answer

osm2pgsql windows "illegal option -W" error

tI'm trying to import map data into a postgis DB on windows. I've doing this for years using osm2pgsql but the latest update of Spain map generates a duplicate key error. It seems to be a 64 bit version issue. Is there a way to avoid this problems?…
naaas
  • 47
  • 1
  • 6
2
votes
1 answer

Connection between Postgis database and Mapnik

Hi I am trying to render mine postgis data into Mapnik , but not being able to do the same, Can any one share with me the Python file for the same , which explanes how to do the same. Manish Sharma
manish sharma
  • 21
  • 1
  • 3
2
votes
2 answers

Querying directly is much, much slower than subquery with join

I have 2 tables. Their structure is roughly as follows; I've changed the names, though. CREATE TABLE overlay_polygon ( overlay_polygon_id SERIAL PRIMARY KEY, some_other_polygon_id INTEGER REFERENCES some_other_polygon (some_other_polygon_id) …
jpmc26
  • 28,463
  • 14
  • 94
  • 146
2
votes
1 answer

Adding a polygon directly in Geodjango/PostGIS

I'm messing around with Geodjango, and I just want to add a simple polygon field to a database and then run a point-in-polygon on it to to make sure everything is working okay. Here's my code in views.py: #adding a polygon pe =…
Steve
2
votes
1 answer

PostGIS: ST_Intersects() between two geographies, sometimes returns false result

I have a problem with an intersect between two geographies in PostGIS: I have a table1 with a geography-column, filled with multi-polygons in wgs84 (one per line). A second table2 also has a geography-column filled with multi-polygons in wgs84 (one…
2
votes
2 answers

points within a particular distance

I have a table conatining a set of points. I would like to make a query that checks the distance between the points and if the distance is small er than the tolerance it would set the points to just one. Any suggestions how I can accomplish such…
IT_info
  • 707
  • 4
  • 16
  • 36
2
votes
0 answers

self join query issues with PostGIS

I have a table and I am doing a self join on it with geo-spacial functions fro PostgreSQL. Now I am expecting to build the point of intersections of each intersection except for those that has the attribute 'tunnel_road' having same…
IT_info
  • 707
  • 4
  • 16
  • 36
2
votes
1 answer

spatial data query

I have the following query which does a self join with a table and outputs all the points of intersections between lines. insert into road_intersection select nextval('road_intersection_id_seq'), a.road_id, b.road_id, st_intersection(a.road,…
IT_info
  • 707
  • 4
  • 16
  • 36
2
votes
1 answer

generate json with PostgreSQL

I have postgreSQL 8.4+PostGIS 1.5. I want to generate GeoJson. I do: SELECT row_to_json(fc) FROM ( SELECT 'FeatureCollection' As type, array_to_json(array_agg(f)) As features FROM (SELECT 'Feature' As type , ST_AsGeoJSON(lg.the_geom)::json As…
Kliver Max
  • 5,107
  • 22
  • 95
  • 148
2
votes
1 answer

ST_Covers: Geography Implementation is not working, Geometry Implementation taking too long

I have a query: (This query uses geographical implementation of ST_Covers function) SELECT ST_Covers(ST_GeoGraphyFromText('MULTIPOLYGON(((179 -89,179 89,-179 89,-179 -89,179 -89)))'),ST_GeographyFromText('POINT(20 30)')); When I run this query it…
khobab
  • 277
  • 5
  • 16
2
votes
1 answer

How to find the elevation of a lon/lat polygon

I am trying to create an application that uses terrain information about an area. I use lon/lat (4326) polygons from a kml file and store the geometries in postgis. I need to find the elevation fluctuations of a particular area (polygon) defined by…
Mike Vasi
  • 467
  • 2
  • 5
  • 16
2
votes
2 answers

Changing the data type of a column in PostgreSQL 9.1

I'm learning PostgreSQL and PostGIS through "PostGIS in Action" book. My problem comes from Pg. 66 in Listing 3.4. My code is as follows: CREATE TABLE ch03.paris_polygons(tags hstore, CONSTRAINT paris_polygons_pk PRIMARY KEY (gid) ) INHERITS…
Zach
  • 185
  • 12
2
votes
1 answer

OpenLayers scale: What is the unit size?

I have a flat game-world map that I've rastered with gdal2tiles.py (-p raster, obviously, as it has not geolocation info). Displaying it as a TMS layer works just fine. I also have vector data I want to overlay. Through trial and error, I've found a…
Tom
  • 2,688
  • 3
  • 29
  • 53