2

I am currently doing fieldwork on little owls. Part of this is noting down on a map where I hear their sounds coming from. These points I later transfer to QGIS (image 1).

enter image description here

Sometimes the owl moves while I'm recording data, so I have two different locations for the same individual (image 2).

enter image description here

I would like to connect these different locations with a line in QGIS. The lines need to be grouped per date, so the line only links the locations of the individual together of one certain date (so not all the locations the individual was heard from on different dates). I hope this makes sense.

How could I do this in QGIS? I've tried points to path, but this connects all the locations of the individual, so not sorted per date.

4
  • Can you add a screenshot showing your points and the attribute table? Are there only one owl per date?
    – BERA
    Feb 18, 2022 at 18:08
  • Thanks for replying BERA! I will add the screenshots. And no there is multiple owls per date and per location
    – Roos
    Feb 21, 2022 at 15:58
  • individ is the unique invividual identifier?
    – BERA
    Feb 21, 2022 at 16:26
  • Yes! It is unique per date per 'heardfrom' location!
    – Roos
    Feb 22, 2022 at 15:29

2 Answers 2

4

(QGIS 3.22.3) In the Points to path tool, you can use an expression in the Path group expression option to group your data.

Click the button on the right of the field to open the expression editor.

enter image description here

Enter this expression. "date" and "indiv" are field names from your point layer, || is the concatenate operator. Be careful with double " and single ' quotes. Double quotes are for field names, single quotes are for strings.

"date" || '_' || "indiv"

It concatenates the date, an underscore, and the individual's ID. The result of the expression would look something like 2022-02-21_1 (and so on for each combination of date and indiv).

enter image description here

You won't see this calculated anywhere (except in the preview in the lower left of the expression editor). But the Paths to points tool will use it to group your points.

The paths are then generated per group.

enter image description here

It just so happens than owl 3 in my randomly generated data set only had a single observation per date and therefore didn't 'move'.


Variation:

For a more explicit version of the same concept (which will work on QGIS versions before the Path group expression option was added), you can use Field Calculator (with the same expression "date" || '_' || "indiv") to generate the groups in a new Text field (called group).

enter image description here

And then select this field in the Group field of the Points to path tool

enter image description here

10
  • Thank you Matt! I will try this out, hopefully it works!
    – Roos
    Feb 22, 2022 at 15:29
  • I'm sorry Matt, I am afraid I do not understand this completely (I am a real QGIS newbie, I'm sorry). Where can I find the "path group expression option" in the points to path function? And should I then add this expression for every date and every individual that needs to be grouped?
    – Roos
    Feb 23, 2022 at 12:00
  • No problem, we were all newbies once. I have updated my answer with some clarifications. You only need to make the expression one time. It will be calculated on every row of your attribute table, using the values it finds in the two fields.
    – Matt
    Feb 23, 2022 at 13:27
  • Hello Matt! I do not see that expression , this is what I see in the points to path tool: link
    – Roos
    Feb 24, 2022 at 11:34
  • It must be a feature added in a more recent version of QGIS. You can use the second part of my answer in that case, and make the groups with the field calculator (after the title "Variation").
    – Matt
    Feb 24, 2022 at 11:35
0

To visualise lines between grouped points you can use Geometry Generator on a layer symbol in the point symbology.

enter image description here

Expression:

make_line(
    array_agg(
        expression:=$geometry, 
        group_by:=date||heardfrom||indiv,
        order_by:=heardfrom
    )
)

enter image description here (I added the labels and colours to better visualise the example).

Note:

It is not a perfect solution as outlined in this question, but it will update dynamically as the point layer is edited.

4
  • Thank you very much Matt! I will try this out! And if I do want to analysis on the layer, I should rerun the tool everytime? How do I do that? I have tried to find out, but cannot really see it.
    – Roos
    Feb 25, 2022 at 14:44
  • There is no need to rerun this version. It will update automatically if new points are added, or existing points moved. It is just the layer symbology, it doesn't produce any data, and therefore not suitable if you need to do analysis on the lines, but for visualisation purposes it is much easier than the Points to path method.
    – Matt
    Feb 25, 2022 at 14:45
  • Does this only work with new points I added and not retroactively? Because I just tried it, but it didn't draw the lines between the points I added today.
    – Roos
    Feb 25, 2022 at 14:55
  • Provided the attributes of the new points meet the conditions for the group then they will be connected. I am doubting if you should have heardfrom as part of the group condition, but I am not familiar with your data (collection). Currently, the points will only be connected if they are the same indiv, same date and same heardfrom. Which means they will not be connected if the owl moved to a different heardfrom area. I am not sure if I am interpreting your data correctly though.
    – Matt
    Feb 25, 2022 at 15:05

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.