0

I have a postgis 2.2 table with 20 columns of type geometry(Point,4326)

I'd like to generate a polygon which covers the outer boundary of the points - it seems like ST_ConcaveHull is a good option, but I can't see how to do it without first converting my points back to text (which seems to be missing the point).

Is st_concavehull the right option, and how do I go about constructing the query?

2
  • few questions: 1. There is in Your table 20 columns with points (like mytable(point1 geometry(Point,4326), point2 geometry(Point,4326) ...,point20 geometry(Point,4326)), right? What do you want to do with this polygons? ST_ConcaveHull or ST_ConvexHull are the right options but I need more data to create some answer
    – Jendrusk
    Nov 23, 2016 at 12:50
  • You need to union or collect the individual points into a single shape before generating the hull. Using text might not be slower, whether it's the point or not. Since you haven't provided the names of your geometry columns or your SQL to generate text, providing a SQL answer is more difficult than it ought to be. Pleaseedit your question.
    – Vince
    Nov 23, 2016 at 12:57

1 Answer 1

1

Some 'ugly but working' resolution on example :

Let's create a table:

create table test_concave (
  point1 geometry, 
  point2 geometry, 
  point3 geometry,
  point4 geometry,
  poly geometry);

Now insert some data into it:

insert into test_concave values (
  ST_GeomFromText('POINT(1 0)'),
  ST_GeomFromText('POINT(0 1)'),
  ST_GeomFromText('POINT(-1 0)'),
  ST_GeomFromText('POINT(0 -1)'),
  null)

Now We'll update column 'poly' with ST_ConcaveHull:

update test_concave set poly = 
  ST_ConcaveHull(
    ST_Collect(
      ST_Collect(
        ST_Collect(point1,point2)
      ,point3)
    ,point4)
  ,1);

The ugly part is that You need as many ST_Colleect functions as many you have geometry columns -1.

Answer as good as good was the question, but maybe it'll help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.