6

My dataset is around 200 days worth of data on the daily distance travelled by a troop of monkeys. I've never properly used QGIS on my own so don't really know where to start. All of the days are together in one dataset. Basically, what I need to do is calculate how far the monkeys travel each day.

The picture is a sample of my dataset. The monkeys were followed throughout the day and a waypoint of their daily travel was taking every 20 minutes. So, I have an update of how far they have moved every 20 minutes and basically want to calculate how far they have traveled throughout the whole day using these waypoints.

enter image description here

6

Sounds like a use case for Trajectools - Day trajectories from point layer. It creates lines from timestamped points, e.g. here is an example of three days of ship movement:

enter image description here

Computing the length per line can then be done as described by Gabriel.

While the tool should be easy to use, the installation is a bit involved on Windows since the plugin requires GeoPandas but there's a step-by-step guide.

  • Is this method okay to use considering my dataset is grouped together and will have to be seperated by days? I think I have my daily paths now, and just need to calculate the length per line, I attempted to create a new new decimal number (real) type field using the expression length( $geometry), but this didn't work. Please see my reply to Gabriel on why I am struggling. Sorry - like I say I've never used QGIS before. – Annie Bailey Feb 17 at 16:15
  • 1
    Yes, there one parameter of the "Day trajectories" tool is the trajectory ID field, so there is no problem with multiple moving objects in the input layer. – underdark Feb 17 at 18:37
4
  • First, you need a field populated with the day, to later group the waypoints by day.

In your case, you can create a new string type field and populate it in the field calculator with the expression:

substr( "name", 6, 7)

It will extract a substring of the "name" field, starting in the 6th character, and with a length of 7 characters (i.e., 21APR16). If you need to group by name and day, you can extract the substr( "name", 1, 12) to obtain unique values for each name and day (i.e., 0940 21APR16).

  • Then, you need to convert the waypoints to paths, grouped by the day field, sorted by the timestamp. Use the Points to path tool.

The output is a new Paths layer, with lines connecting the waypoints for each day.

  • Finally, you can create a new decimal number (real) type field in that layer, and populate it in the field calculator with the following expression:

length( $geometry)

That expression returns the planimetric length of each feature of the layer. Use it with a projected layer. If you have all your data in geographic coordinates, you can define the ellipsoid in the CRS Project Properties and use the $length expression instead, to return the ellipsoidal length.

  • Hi Gabriel, thanks a lot for you help. I've managed to convert the waypoints to paths via your instructions. However, I attempted to create a new new decimal number (real) type field using the expression length( $geometry), but this didn't work. My output comes out as null. Do you have any idea where I could be going wrong? My data are in GPS coordinates yes, so would I be using the second suggestion instead? If so, could you possibly explain this a little more? Sorry - I'm really new to QGIS and am struggling even with the simple things! – Annie Bailey Feb 17 at 15:54
  • 1
    Hi Annie, are your paths now a layer of lines? You must add a field in the attribute table of that layer, and populate that field with the expression. If you try to calculate the length in the points layer the expression returns NULL, because the points don't have a length. I can not think of more details to add. Yes, use the second option, choose the WGS 84 ellipsoid and calculate the ellipsoidal length for each line in a field populated with $lengthinstead. – Gabriel De Luca Feb 17 at 21:44
  • Excellent answer. So, just to clarify, using $length has converted ellipsoidal length to length in meters? – Annie Bailey Feb 18 at 14:29
  • 1
    Ellipsoidal length is the curved distance measured over the ellipsoid, units can be any distance dimension, setted below the ellipsoid in the project properties. Planimetric length is the distance measured over the flat map, in the units of the layer CRS. Since your layer has a geographic (not projected) reference system, and its units are degrees, the planimetric distance returns a "degrees distance", but degrees are angular dimensions and the relation between angular and planimetric dimensions can not be established without a projection. – Gabriel De Luca Feb 18 at 16:18

Your Answer

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

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