Movement data in GIS extra: trajectory generalization code and sample data
Today’s post is a follow-up of Movement data in GIS #3: visualizing massive trajectory datasets. In that post, I summarized a concept for trajectory generalization. Now, I have published the scripts and sample data in my QGIS-Processing-tools repository on Github.
To add the trajectory generalization scripts to your Processing toolbox, you can use the Add scripts from files tool:
It is worth noting, that Add scripts from files fails to correctly import potential help files for the scripts but that’s not an issue this time around, since I haven’t gotten around to actually write help files yet.
The scripts are used in the following order:
- Extract characteristic trajectory points
- Group points in space
- Compute flows between cells from trajectories
The sample project contains input data, as well as output layers of the individual tools. The only required input is a layer of trajectories, where trajectories have to be LINESTRINGM (note the M!) features:
In Extract characteristic trajectory points, distance parameters are specified in meters, stop duration in seconds, and angles in degrees. The characteristic points contain start and end locations, as well as turns and stop locations:
The characteristic points are then clustered. In this tool, the distance has to be specified in layer units, which are degrees in case of the sample data.
Finally, we can compute flows between cells defined by these clusters:
If you use these tools on your own data, I’d be happy so see what you come up with!
This post is part of a series. Read more about movement data in GIS.
Does the shp. need to be specially prepared for this script? I have a layer of roads when I run the extract characteristic trajectory scripi, script make points, but when I start the group point in space, the script is started and it stands, and nothing happens. Where am I wrong?
Group points in space should work on any points and should have no dependencies on the previous step. Are you certain that the cluster size that you specified fits the data? It has to be specified in layer units.
I have forest road layer in small municipality. Layer has metric units and coordinates are also. I am Austria neighbor. What size of cluster has to be?
Depends on the distance between significant points.
That noted, it does not make much sense to apply trajectory generalization on a simple road network layer. There are other ways to simplify road networks.