8

How to convert points data to polygon, enter image description here so as to form polygon from exterior point as shown above

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
user28344
  • 93
  • 1
  • 3

1 Answers1

6

I would create a geometry collection from the points using st_collect(): http://postgis.net/docs/ST_Collect.html

Then I would create convex hull from the point collection: http://postgis.net/docs/ST_ConcaveHull.html

If you have a table of point geometries called testpoints where geometry column name was the_geom, this should create the polygon that you are looking for:

SELECT st_astext(st_concavehull(st_collect(the_geom),0.99))
FROM myschema.testpoints;
Taras
  • 32,823
  • 4
  • 66
  • 137
DavidF
  • 4,862
  • 1
  • 26
  • 32
  • If you are looking for a good PostGIS book, the new PostGIS Cookbook from PACKT is very good. – DavidF Mar 21 '14 at 18:33
  • thanks david, your query works on a simple points, but not good enough on complex points. – user28344 Mar 22 '14 at 01:59
  • Can you provide an example or define what you mean by complex points? Multi-point features? I am pretty sure that the query that I provided will correctly solve the problem that you diagrammed. – DavidF Mar 22 '14 at 18:01
  • This my point

    i use concavehull with 0.5 %

    – user28344 Mar 24 '14 at 07:53
  • I think the trick is that there is no magic solution that fits all point sets. The computer doesn't know what you want it to look like in the end. st_concave_hull starts with a convex hull and then 'shrink wraps' it based on your value for target percent. I would increase the value of your target percent. – DavidF Mar 24 '14 at 13:27