Using PostGIS, I'm trying to solve the following problem:
I have trajectory data (coordinates from API query), like on this image:
and want to convert it into polygon, having only outer edges:
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.
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...