3

I have a set of lat/long points which represent positions along a set of paths (the points are generated by satellite collars on several animals that we are tracking), and I want to link the points with lines, by sorting the points by date/time and grouping them by animal ID. The plugin Points to Paths, available at the old repository has the very handy feature of being able to split a big dump file by animal ID and create a path for each animal, which the newer plugin Points2One does not.
Unfortunately I get an error message saying that PointsToPaths is no longer supported and is not compatible with my version (1.9.0) of QGIS. It is sad to see such a good plugin disappear.

Can anyone suggest a fix or an alternative? My data are in PostgreSQL with PostGIS. I assume that there is probably a clever but complicated solution using PostGIS, but in the spirit of laziness I am hoping that I am just missing some really simple ready-made solution.

Thanks!

1 Answer 1

2

PostGIS has a built in function called ST_MakeLine(), taking e.g. an array of points as argument. You can then create a stored procedure to convert your data and create a new table with line geometries and their respective attributes.

5
  • Better yet, use this function to create a view and whenever you add new points into the data table, the lines will be dynamically generated on-the-fly. Aug 19, 2013 at 18:39
  • 2
    Not necessarily "better bet", if there is more than a small amount of data the line building operation will start to make accessing the views punitively slow. However, PgSQL 9.3 offers materialized views, so there's light at the end of the tunnel... Aug 19, 2013 at 19:44
  • Yep, a view would probably be too slow in cases where speed is needed (e.g. live maps online). I have worked on a project where we ended up running stored procedures in cases whre huge amount of geometries had to be processed. Materialized is definietly a good alternative.
    – Oyvind
    Aug 19, 2013 at 20:37
  • Perfect -- thank you all very much for the solution and for introducing me to materialized views. I want to get these data online, so that discussion was also very useful-- exactly what I was hoping for.
    – John
    Aug 20, 2013 at 1:58
  • Thank you for giving some good guidelines for using tables vs views vs materialized views. Aug 20, 2013 at 4:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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