Movement data in GIS #20: Trajectools v1 released!

In previous posts, I already wrote about Trajectools and some of the functionality it provides to QGIS Processing including:

There are also tools to compute heading and speed which I only talked about on Twitter.

Trajectools is now available from the QGIS plugin repository.

The plugin includes sample data from MarineCadastre downloads and the Geolife project.

Under the hood, Trajectools depends on GeoPandas!

If you are on Windows, here’s how to install GeoPandas for OSGeo4W:

  1. OSGeo4W installer: install python3-pip
  2. Environment variables: add GDAL_VERSION = 2.3.2 (or whichever version your OSGeo4W installation currently includes)
  3. OSGeo4W shell: call C:\OSGeo4W64\bin\py3_env.bat
  4. OSGeo4W shell: pip3 install geopandas (this will error at fiona)
  5. From https://www.lfd.uci.edu/~gohlke/pythonlibs/#fiona: download Fiona-1.7.13-cp37-cp37m-win_amd64.whl
  6. OSGeo4W shell: pip3 install path-to-download\Fiona-1.7.13-cp37-cp37m-win_amd64.whl
  7. OSGeo4W shell: pip3 install geopandas
  8. (optionally) From https://www.lfd.uci.edu/~gohlke/pythonlibs/#rtree: download Rtree-0.8.3-cp37-cp37m-win_amd64.whl and pip3 install it

If you want to use this functionality outside of QGIS, head over to my movingpandas project!

10 comments
  1. Theo Berkhout said:
    Theo Berkhout's avatar

    This is great! Exactly what I was looking for. Thanks

  2. Theo Berkhout said:
    Theo Berkhout's avatar

    It would be nice if the trajectories made could also be Polyline-M and/or Polyline-Z strings

    • underdark's avatar

      Outputs should be LINESTRINGM already. Do you mean MULTILINESTRINGM?

      • Theo Berkhout said:
        Theo Berkhout's avatar

        OK, thanks, I will check that out!

  3. urbanistalepe's avatar

    Hi Anita,
    I´m Lepe and i have a question..
    What’s heading?

    Thanks!

    • underdark's avatar

      Hi Lepe,
      Heading as I used it here is the direction/course of a person’s or vehicles movement. (I’m aware that in navigation, heading is the direction a person or vehicle is facing, and not necessarily the same as its course, but ignored that fact when naming the function.)

  4. Raza said:
    Raza's avatar

    It seems very interesting. currently, I am working on GPS trajectory data but I do not know what is the issue in python and QGIS. It gives me the following error.

    ImportError: C extension: No module named ‘pandas._libs.tslibs.conversion’ not built. If you want to import pandas from the source directory, you may need to run ‘python setup.py build_ext –inplace –force’ to build the C extensions first.

    • underdark's avatar

      I haven’t encountered this error before. Which operating system are you using? (If Windows: Did you follow the instructions provided at https://github.com/anitagraser/qgis-processing-trajectory?)

      Since it seems to be an issue with installing Pandas, the corresponding community should know best how to fix it.

  5. bruceb said:
    bruceb's avatar

    Hi Anita, this is a great improvement. I would also like to be able decide a maximum distance and or duration between points to decide whether the points should be in the same trajectory or start a new trajectory.