Order in PostGis multipoints

I am using PostgreSQL (9.5) and PostGIS (2.2.2).

I need to create a multipoint geometry while keeping track of the order of the points. (I would assume the point order to be the same order as the one used while creating the geometry).

geom = public.ST_GeomFromEWKT('SRID= 3067; MULTIPOINT((6703022 329690),(6702875 329189), (6706855 321939), (6706937 321896))')

Point 1: (6703022 329690) ; Point 2: (6702875 329189) ; Point 3: (6706855 321939) ; Point 4: (6706937 321896)

What would be the best approach?

Having one table with a geometry column or having two tables, one has all the other attributes and the other one has relations to the first table with the points and an id to give some order?

I also would like to know if it is possible to extract the n-th element of a multipoint (for instance the 3rd point).

For instance from the geom example above, I would like to get the Point 3... The return value should be (6706855 321939).

The same question applies for the first and last elements of the geometry. And by the way, is there a way to know how many points are in a multipoint geometry?

Asking how many points are in the geometry of the first example would return 4.

I have been trying to read the documentation about multipoints in the postgis reference but it seems quite confusing for me...

Thanks in advance,



I would use the M dimension to store the order of the points.

Category: postgis Time: 2016-07-28 Views: 0

Related post

  • Merge reversed linestring in correct order in postGIS 2011-09-28

    I want to merge linestring in the correct order in postGIS, but sometime they are reversed so something like this : select astext(linemerge(ST_union( ST_GeomFromText('LINESTRING(3 3, 2 2)'), ST_GeomFromText('LINESTRING(1 1, 2 2)')))); returns this :

  • Change column order in postgis 2.0 2013-09-12

    Is it possible to change the column order of a table in postgresql/postgis 2.0? If so, how is it done? --------------Solutions------------- This type of thing isn't directly supported with PostgreSQL. However, there are many tips on how to alter the

  • How to join LINESTRINGS in a specific order in PostGIS? 2014-11-13

    I have a path from point A to point B, which I want to double back on itself to create a path from A to B back to A. It seemed like using ST_LineMerge on the MULTILINESTRING created by ST_Collect from the two LINESTRINGS was the answer, however it do

  • Can I have two kinds of point geometry in a shapefile or I should create multipoint shapefiles? 2013-09-13

    Following my previous question, can I have a mixture of two kinds of geometry in a shapefile of type point. Just like I have about shapefiles of type polygon or I should always create a shapefile of type multipoint in order to support multipoints in

  • GeoTools and PostGIS with ESPG:3857 2013-10-12

    I'm trying to use both PostGIS and GeoTools with the same ESPG:3857 projection, however, it looks like the projections in PostGIS and GeoTools differ. This is what I have in PostGIS: PROJCS["WGS 84 / Pseudo-Mercator", GEOGCS["WGS 84",

  • PostGis line geometry type 2014-05-12

    I am using postgresql9.3 and postgis2.1.I imported a shape file into my database. In that the_geom datatype is "LINESTRING" . Now i need a query to find the lines within a given radius for a particular latitude, longitude. For Ex: Consider i hav

  • POSTGIS inserts become slow after some time 2016-02-05

    I have a location table with following structure: CREATE TABLE location ( id BIGINT, location GEOMETRY, CONSTRAINT location_pkey PRIMARY KEY (id, location), CONSTRAINT enforce_dims_geom CHECK (st_ndims(location) = 2), CONSTRAINT enforce_geotype_geom

  • How to get routes in the database that intersects circle? 2013-02-07

    I have routes (linestrings) recorded in the database. I want to create a query which returns the routes that have some commonality with a circle whose center and radius are passed as parameter. I tried this way: SELECT * FROM routes WHERE ST_Touches(

  • How to unit test distance calculation beetween to points? 2015-11-17

    I want to write unit test for this query select a.id, b.id from channel a, channel b where ST_Distance_Spheroid( a.coordinates, b.coordinates, 'SPHEROID["WGS 84",6378137,298.257223563]' ) <= 1000.0 and a.id != b.id What this query does is it

  • Querying PostGIS Raster with MultiPoint 2012-11-05

    For one of my projects using PostGIS 2 I have a table with GPS tracks (igc_files). It holds records including a MULTIPOINT() column that has about 1,000 points for each record and a column that has an array of the corresponding timestamps. I also hav

  • How to extract nodes with PostGIS to a multipoint geometry 2014-12-12

    I have a line in a PostGIS table test_line. I want to extract it's nodes into a multipoint geometry. I tried the following: SELECT ST_Collect((ST_DumpPoints(the_geom)).geom) FROM test_line; But it gives me the error ERROR: set-valued function called

  • Extracting specific geometry point from MultiPoint geometry using PostGIS? 2015-03-30

    I am working with multipoint geometries in postgis and would like to extract the geometry point associated with the greatest y value of the multipoint geometry. How may I accomplish such a task? For example, if my multipoint geometry is defined as fo

  • Problem loading OS OpenData multipoint shapefile into PostGIS 2011-01-17

    I am trying to load the OS OpenData Strategi shapefile dataset into a PostGIS database. I have had no problems with the polyline and polygon shapefiles, but I am unable to get the point shapefiles to load. I am using the following shp2pgsql command l

  • Order for inserting data into postgis 2011-06-12

    I am using postgis for my project along with geoserver and openlayers. I give user an html form with drop down menu list of available layers(each layer corresponds to a table in db).The user can select any layer , based on which I am retrieving the f

  • How to get an array of simple lines from one multipoint linestring in PostGIS? 2011-08-18

    How can I extract some LINESTRING consisting of 3 or more POINTs to several LINESTRINGs each of 2 POINTs in PostGIS? --------------Solutions------------- That should do: SELECT a.id, ST_MakeLine(ST_PointN(the_geom,x),ST_PointN(the_geom,x+1)) FROM ori

  • PostGIS - table with 3d points with fast ordering by distance 2012-05-24

    I am pretty new to PostGIS and I am trying to solve the following problem. I need a table with 3D points (x,y,z) that will contain around 1-10million points. I want to be able to efficiently ask the table for 100-1000 points that are closest to some

  • How to change the geometry type from Point to Multipoint within an existing table in PostGIS? 2012-07-04

    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. --------------Solutions---

  • How does one control the rendering order of geometries from a postgis geometrycollection? 2012-07-10

    I have been using PostGIS for a while now but have only been using simple geometries (points,polylines and polygons). For a particular project of mine I am considering using the geometrycollection format. But I need some help understanding the concep

  • postgis union geometries in consecutive order 2013-03-05

    Database is postgres 9.2, POSTGIS="2.0.2 r10789" GEOS="3.3.6-CAPI-1.7.6" PROJ="Rel. 4.7.1, 23 September 2009" LIBXML="2.7.8" i have geometries in consecutive order. Here is query: SELECT (ST_Union(geom)) FROM roads

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.529 (s). 13 q(s)