I have a table with latitude, longitude representing paths. I want to simplify the paths using Postgis ST_Simplify

Here is a sample set of 89 GPS points i try to simplify : https://gist.github.com/vdaubry/ab57027d8100495bdf261478808a8a50

I expect the result to be a smaller list of GPS points representing a similar shaped path.

When i run ST_Simplify on this set i only get 2 points as a result.

Can you help me debug this query ?

SELECT ST_X((result.points).geom) AS latitude, ST_Y((result.points).geom) AS longitude
  SELECT ST_DumpPoints(simplified_path.simplifiedLine) AS points
  FROM (
    SELECT ST_Simplify(ST_MakeLine(path.point), 3) as simplifiedLine 
        FROM (
            SELECT ST_SetSRID(ST_MakePoint(latitude, longitude),4326) AS point
            FROM tour_points
            where tour_id=369
            ORDER BY passing_time ASC
       ) as path
    ) simplified_path
) result

P.S: I tried playing with the tolerance parameter but i always end up with only 2 points.

  • 1
    The second parameter of ST_Simplify is in degree, 3 degree > 300 km on the surface on the Earth! One arc second is about 30 meters. If you would like a tolerance of three meters then use one tenth of arc second e.g. 0.00003 in degree. – Zoltan Dec 24 '16 at 12:23

Your Answer

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

Browse other questions tagged or ask your own question.