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
1
vote
1 answer

PostGIS point attributes to polygons, where poligon contain point

I have a polygon database (bdus) and a point database (bdps) under the same schema in PostGIS. These databases were imported from shapefiles with the Shapefile and DBF loader. What I want to do is to join the point attributes on the polygon layer…
user1165791
  • 111
  • 1
  • 1
  • 4
1
vote
2 answers

Query to find distance between a point column and a point in PostGis

I am using PostGis for Location based calculations in my Application. In a Table i have a column called 'location' in geography type(Point(lon lat))...Like this number of rows present in the Table. I want to pass a point(Point(lon lat)) and check…
Ramprasad
  • 7,981
  • 20
  • 74
  • 135
1
vote
1 answer

postgis split polygon using points

I would like to extract polygon parts using points to cut it. I have seen ST_Dump and ST_Split but they do not seem to do the trick. Should I create more points in order to create a line segment and use st_split to cut them? I think thats too much…
Antony
  • 15,257
  • 4
  • 17
  • 18
1
vote
1 answer

Is it possible to convert from Geography to Geometry in PostGIS?

I have a shp file that has geography types, Can I convert it with a tool like shp2pgsql? or is there a postgis function to do that?
Paco Valdez
  • 1,915
  • 14
  • 26
1
vote
1 answer

python postgis ST_ClosestPoint

I am struggling with an SQL command issued from my python script. Here is what I have tried so far, the first example works fine but the rest do not. #working SQL = "SELECT ST_Distance(ST_Transform(ST_GeomFromText(%s,…
Antony
  • 15,257
  • 4
  • 17
  • 18
1
vote
1 answer

How to get the Nth LineString from a MultiLineString in PostGIS?

I need a way to get the Nth LineString from a MultiLineString in PostGIS / PostgreSQL, something like ST_PointN that gets the Nth point from a LineString.
Paco Valdez
  • 1,915
  • 14
  • 26
1
vote
2 answers

Does this statement hit the database?

I have a .NET application which executes a statement like this: SELECT ST_GeomFromKML(' -71.1663,42.2614 -71.1667,42.2616 '); There is no need for…
capdragon
  • 14,565
  • 24
  • 107
  • 153
1
vote
1 answer

How can I create a model with compound foreign key?

anybody knows on how to create a model with compound foreign key to another model. e.g. UserInfo: userId, password, key, ... GeoInfo: id, userId, password, storeName, ... In the above sample models. Want to link GeoInfo to UserInfo using two fields…
eros
  • 4,946
  • 18
  • 53
  • 78
1
vote
2 answers

How can I read WKT from the shapefile .prj?

I am building a system which lets users upload shapefiles. It then converts those shapefiles to PostGIS using shp2pgsql. This command requires the SRS ID in form of an EPSG code. So I need a ruby gem that can read the shapefile's *.prj file (which…
Sareuon
  • 637
  • 1
  • 7
  • 9
1
vote
1 answer

postgresql st_asgeojson returns not readable value

I'm trying to make this data to geometry, but for some reason postgresql returns not readable values. I need latlng.... I can't use that value to draw marker at all. what am i missing here? please help. postgresql v. 11 insert into area(latlng)…
1
vote
0 answers

How to get the lines outside the polygon

I would like to cut my lines according to the polygon. And I want to keep only the cut lines that are outside the polygon. The cutting must be done at the intersections. The result I get is not satisfactory because the lines are not cut properly at…
Bak
  • 411
  • 1
  • 5
  • 19
1
vote
1 answer

PostGIS saving Point as VARBINARY - Invalid endian

I am trying to add a Point to a Postgres database and hibernate is not recognizing the Point type. Entity: @Table(name = "test_locations") public class TestLoc { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer…
lemario
  • 388
  • 1
  • 3
  • 17
1
vote
0 answers

Extract POLYGON or MULTIPOLYGON from GEOMETRYCOLLECTION

in my table, I have a geometry field. I realize that there are GeometryCollection type. There are lines and polygons, it creates a lot of problems when I do processing with st_intersections. I would like to convert the GeometryCollection into…
Bak
  • 411
  • 1
  • 5
  • 19
1
vote
1 answer

Postgis: Restrict geography POINT coordinates values +-90 +- 180

I have a following table and i would like to ask a question regarding coordinates check constraint. create table places ( id bigint generated always as identity constraint pk_places primary key, name …
Aleksei Khatkevich
  • 1,923
  • 2
  • 10
  • 27
1
vote
1 answer

Postgresql (Postgis) parallel triggers on insert

I have a table the following table: CREATE TABLE pois ( id bigserial NOT NULL, name int8 NOT NULL, point point.geometry(point) NOT NULL ); I want to make pois unique by ST_DISTANCE < 0.00001. What i mean: Inserting 2 records: INSERT INTO pois…
linderman
  • 149
  • 1
  • 9