Using PostGIS, I'm trying to solve the following problem:

I have trajectory data (coordinates from API query), like on this image:

Raw trajectory

and want to convert it into polygon, having only outer edges:

enter image description here

  • Create polygon from polyline then union – BERA Nov 23 '18 at 17:57
  • @BERA As I'm new to PostGIS, by create polygon, you mean POLYGON((...))? That results invalid polygon, but can be made valid with ST_MakeValid(), but then what? – Jason Nov 23 '18 at 18:33

You may use ST_ConcaveHull for your purpose: The concave hull of a geometry represents a possibly concave geometry that encloses all geometries within the set.

| improve this answer | |

Option 1 - create table tbl2 as SELECT (ST_ConcaveHull (ST_Collect (geom), 0.99)) as geom FROM tbl1 Option 2 - 1: create table tbl2 as SELECT ST_Intersection (a.geom, b.geom) as geom FROM tbl1 as a, tbl2 as b WHERE ST_Intersects (a.geom, b.geom); 2: delete from tbl2 WHERE GeometryType (geom) = 'LINESTRING' 3: Run on tbl2 ST_DelaunayTriangles 4: Remove the extra triangles and union over triangles...

| improve this answer | |
  • Option 1-very roughly (with buffering) can solve Your problem; Option 2 - is given due to the fact that you have in the figure there are open geometry in the form of a line and this method cuts open lines from processing... – Cyril Mikhalchenko Nov 25 '18 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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