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
10
votes
8 answers

CREATE EXTENSION postgis fails,

I am on Ubuntu 18.04 with the psql (PostgreSQL) 12.2 (Ubuntu 12.2-2.pgdg18.04+1) Running temba=# create extension postgis; fails with the following error ERROR: could not open extension control file…
nishon.tan
  • 969
  • 2
  • 8
  • 21
10
votes
2 answers

Why does running a query return 'table_oid' under messages and nothing under Data Output

Running any sort of query on pgAdmin 4 just returns a 'table_oid' under messages. I am able to get the necessary data when running the query from the command line, for example SELECT ST_MakePolygon(ST_GeomFromText('LINESTRING(75.15 29.53,77 29,77.6…
Philip Wee
  • 113
  • 7
10
votes
2 answers

Rails with PostGIS

First of all, I'm using Rails3 with Ruby 1.9.2. I have a problem using PostgreSQL with PostGIS. I've tried two gems: https://github.com/nofxx/georuby https://github.com/rgeo/activerecord-postgis-adapter The problem is, that the first one from…
23tux
  • 14,104
  • 15
  • 88
  • 187
10
votes
6 answers

Order by nearest - PostGIS, GeoRuby, spatial_adapter

I'm trying to do an order query that finds records nearest to the current_user. I know the distance between the two points is: current_location.euclidean_distance(@record.position) How can I work this into a PostGIS (or…
DanS
  • 17,550
  • 9
  • 53
  • 47
10
votes
2 answers

What SRID should I use for my application and how?

I'm using PostgreSQL with PostGIS. All my data has already decimal lat/long attached to it (i.e. -87.34554 33.12321) but to use PostGIS I need to convert it to a certain type of SRID. The majority of my queries are looking for data inside a certain…
avatar
  • 12,087
  • 17
  • 66
  • 82
10
votes
1 answer

How to convert from PostgreSQL to GeoJSON format?

I have a simple table called"imposm3_restaurant" with columns [ id, name, geometry] I want to convert these data into geoJSON, I am using this function CREATE VIEW imposm3_restaurants_geojson AS SELECT row_to_json(fc) AS geojson FROM (SELECT…
Alex
  • 315
  • 2
  • 5
  • 14
10
votes
2 answers

Rails + Postgis: error cannot drop table spatial_ref_sys

Rails 5 Postgresql 9.4.10 Postgis 2.1.8 when I try rake db:reset, console show an error rake aborted! ActiveRecord::StatementInvalid: PG::DependentObjectsStillExist: ERROR: cannot drop table spatial_ref_sys because extension postgis requires it…
Bye
  • 732
  • 8
  • 29
10
votes
2 answers

How to use asynchronous feature of pyscopg2?

I'm trying to execute 3 different postgresql queries with different table. Each query takes 2 seconds to execute. I was wondering if it's possible to run all 3 queries at the same time so that I can save 4 seconds. I tried using the asynchronous…
Rahul
  • 3,208
  • 8
  • 38
  • 68
10
votes
1 answer

Hibernate 5.1 with Postgis 2.2 geometry columns mapping

Documentation for hibernate 5.1 spatial is not yet released (AFAIK) and I'm trying to persist entities with JST geometries fields to PostgreSQL 9.5 + Postgis 2.2, without any luck. I've also noticed that there is no org.hibernate.spatial package in…
Mihai Serban
  • 406
  • 2
  • 7
  • 18
10
votes
2 answers

Difficulty serializing Geography column type using sqlalchemy marshmallow

I an trying to use Marshmallow to do do deserialize and serialise SQLAlchemy objects but run into a problem when dealing with Geography fields in the ORM. Firstly the model: class Address(db.Model, TableColumnsBase): __tablename__ = 'address' …
silverdagger
  • 1,124
  • 13
  • 37
10
votes
1 answer

Rails db:structure:dump has incorrect search paths

I am using db/structure.sql to preserve our DB State as we have PostGIS extensions and built in functions that make using schema.rb impractical. When running db:structure:dump rails has the odd behaviour of setting search paths near the top AND near…
Chris Noldus
  • 2,432
  • 2
  • 20
  • 27
10
votes
4 answers

PostGIS extract coordinates from POLYGON

I'm trying to extract latitude / longitude values from a polygon column in PostgreSQL that I created using the PostGIS extension, I tried get the coordinates using a query like this Query ST_AsText(coverage_area) as coverage_area But the output it…
Harry Geo
  • 1,163
  • 3
  • 10
  • 24
10
votes
1 answer

Python SQLAlchemy: Mapping a PostGIS geom field

SQLAlchemy maps DB columns to object members in Python. For example: class User(Base): __tablename__ = 'users' id = Column(Integer, Sequence('user_id_seq'), primary_key=True) name = Column(String(50)) fullname = Column(String(50)) …
Adam Matan
  • 128,757
  • 147
  • 397
  • 562
10
votes
2 answers

PostGis Distance Calculation

I am doing a indoor map navigation application right now and what I am trying to do is to build a database of map point in the building. All of the coordinate I use is taken from Google Map (which means the EPSG is 3857). What I need to do now is to…
Thomas Dang
  • 201
  • 3
  • 4
  • 14
10
votes
3 answers

Postgis - How do i check the geometry type before i do an insert

i have a postgres database with millions of rows in it it has a column called geom which contains the boundary of a property. using a python script i am extracting the information from this table and re-inserting it into a new table. when i insert…
ADAM
  • 3,903
  • 4
  • 29
  • 45