1

I have a table with points in the Postgres. The points are from the flight path. I need to filter out some points. enter image description here.

My question would be how can I select only points which are in line and then make a line from the selected points only if parallel lines are in no more then 20m distance in between lines. Turning points should be ignored. enter image description here

What I have done so far is to select points that are in one line

WITH routes as (
SELECT
geom,
heading-lag(heading) over (order by time) AS direction 
FROM mytable 
)
SELECT direction, geom 
FROM routes WHERE direction between -10 AND 10;

In my query, I calculated direction from heading, and selected points with a minor difference in the heading. However, I don't know how to continue.

EDIT

Link to fiddler data table http://sqlfiddle.com/#!17/3262c/9/0

With my query from above, I can filter the points which are marked in red lines. How can I add those points in variables like line1=... line2=... line3=... line4=... and line5=... ? Thank you for any help.

markus
  • 81
  • 7
  • Please provide us with some sample data, either here or in a SQLFiddle, so we can help you more easily – Ruben Helsloot Aug 24 '20 at 07:38
  • how can I share example data here? I have tried to use fiddler but I get an error when I tried to create postgis extension. – markus Aug 24 '20 at 11:55
  • Create a small CTE/subquery using the VALUES clause. See [here](https://stackoverflow.com/a/63493889/5015356) for an example – Ruben Helsloot Aug 24 '20 at 13:39

0 Answers0