Questions tagged [postgis]

PostGIS is an extension for the PostgreSQL object-relational database that adds support for geographic objects.

PostGIS

PostGIS is an extension for the PostgreSQL object-relational database that enables the storage of geographic objects. PostGIS is designed according to the OpenGIS Simple Feature Access for SQL specification published by the Open Geospatial Consortium.

The current stable version is PostGIS 3.1.1 (released January 28th, 2021). This version works well with PostgreSQL version 13.1.

PostGIS has been developed by Refractions Research and others and is released under the GNU General Public License.

9401 questions
61
votes
2 answers

Inserting point into PostGIS?

I have created one table in my PostGIS nut I cannot insert point. What is wrong with my query? CREATE TABLE app ( p_id INTEGER PRIMARY KEY ); SELECT AddGeometryColumn('app','the_geom','4326','POINT',2); INSERT INTO app(p_id, the_geom)…
Shahjalal
  • 1,163
  • 3
  • 12
  • 16
43
votes
1 answer

How to convert/typecast from Polygon to Multipolygon in PostGIS?

Is there any way to typecast Polygons to Multipolygon type? For example, I have created a circle using ST_Buffer() on a point. The return type of that function is of Polygon type. The problem is that on the geometry column there is a restriction…
Vicky
  • 1,852
  • 3
  • 22
  • 28
36
votes
2 answers

Changing geometry type from Point to Multipoint within existing table in PostGIS?

Is there a PostGIS function that can change geometry type for an existing table? We need to change from POINT to MULTIPOINT. The table will be empty when we change the geometry type and we cannot just drop/create the table.
Ulrik Balslev
  • 361
  • 1
  • 3
  • 3
32
votes
2 answers

What is the Difference between Geometric and Geographic columns?

I am a beginner in GIS and Learning PostGIS. I came across this two terms Geom and Geog, Could anyone explain in brief. What is the best to use with map data and Do all functions support both Geom and geog.
azzaxp
  • 839
  • 2
  • 8
  • 15
30
votes
4 answers

How to get the nearest point on a linestring to a given point?

I've been using PostGIS for a long time now but never had to use the LINESTRING geometry ...! :) Here's what I would like to do : I have a table of linestrings (representing streets of a given city, SRID 3395) and I would like to find the nearest…
Vivi
  • 451
  • 1
  • 4
  • 7
23
votes
5 answers

Using schema other than public in PostGIS?

I'm currently setting up a fresh install of PostGIS 2.0.2 and PostgreSQL 9.1.6 on Ubuntu. I've recently come across some information indicating that using the public schema to store all data is not a good idea. For this reason, I've set up a schema…
Paul
  • 2,009
  • 1
  • 19
  • 28
20
votes
1 answer

PostGIS select by lat/long bounding box

I have a minLat, minLong, maxLat and maxLong from a box drawn on a map. Right now, my query to get all the points in the box looks like this: SELECT * FROM geomTable WHERE (longitude BETWEEN minLon AND maxLon) AND (latitude BETWEEN minLat AND…
bl8rchk
  • 551
  • 1
  • 3
  • 14
20
votes
2 answers

Moving a PostGIS Installation

I have a PostGIS installation running on an old computer that I'd like to move. I spent a bunch of time playing with pg_dump and pg_dumpall without success. It seems the normal dump procedures don't work with PostGIS because file paths get hard…
Seth
19
votes
1 answer

PostGIS: Count number of vertices of lines and polygons in tables

I have 23 tables in a PostGIS schema which I need to count the number of vertices of. The tables are a mixture of lines and polygons so realised I need to use ST_NPoints(geom) So I ran the following query SELECT count(ST_NPoints(geom) FROM…
tjmgis
  • 3,330
  • 1
  • 23
  • 37
19
votes
1 answer

How to retrieve the corners of the bounding box from ST_Extent?

Is there any way to fetch the lat/long of the corners of the bounding box we got from ST_Extent? select ST_Extent(geom) from tableName;
Vicky
  • 1,852
  • 3
  • 22
  • 28
18
votes
1 answer

Is there a PostGIS function for determining whether a linestring intersects itself?

I've been looking for a function that can tell me if a LineString intersects itself. I've tried calling st_intersects with the same LineString twice, but obviously identical linestrings will intersect. My plan if there is no function would be to get…
Jeff
  • 287
  • 3
  • 7
17
votes
2 answers

How to get the geometry type of an empty PostGIS table?

I have a web application that needs to know the geometry type of a PostGIS table's geom field before inserting rows into it. I use the following query to determine the geometry type of the geom column: SELECT GeometryType(geom) FROM…
Tanner
  • 7,375
  • 14
  • 62
  • 109
17
votes
2 answers

postgis update multipolygon with st_makevalid() gives error

I have a table with a few invalid geometries (empty rings, self-intersections). I'd like to fix them up something like this: update mytable set geomcolumn = st_makevalid(geomcolumn) where id = 123; and I get "ERROR: Geometry type…
MC5
  • 1,901
  • 1
  • 14
  • 23
17
votes
1 answer

PostGIS - how to effeciently ST_Union all overlapping polygons in a single table

My goal is take a single table and st_union all polygons that are either touching or close to each other into single polygons I'm a C# developer who is starting to learn about PostGIS. Using the code below, I was able to accomplish this, but it…
15
votes
1 answer

Postgis change geometry type to Polygon

I have a table that has its geometry type as geometry and I need to convert it to Polygon for ogr2ogr to read it. Can't figure this out. I have tried ALTER TABLE oak_all_buffers ALTER COLUMN geom type geometry(MultiPolygon, 102689); error …
ziggy
  • 4,515
  • 3
  • 37
  • 83
1
2 3
43 44