2

I am trying to make an animation with the temporal controller of the locations of animals on specific days and would like to display the proportion in each location. The data are in a text-delimited file and organized similar to this example

Barn Horses observed Color Date checked
A 1 Pinto 2021-12-03
A 2 Black 2021-12-03
C 1 Pinto 2021-07-22
C 0 NULL 2021-04-16
C 2 Pinto 2021-12-03
B 2 Black 2021-07-22

With each barn also corresponding to its gps coordinates. This is the format we used for entry and R. I understand it's not the best for QGIS, but I'm not sure how to reformat it without losing the date column necessary for temporal control.
I made rule-based groupings by making size classes for each color. These can go into point cluster/displacement, but it ends up looking rather... Messy. Ideally I'd like something like barn A shows a 2:1 pie chart for the colors on 2021-12-03 which is scaled by the total number of horses at the barn that day (3) so it looks larger than barn C which only has two pinto. I have an approximate idea for what I could do and seek detailed instructions.

How can I "grab" the number observed for each color when selecting the pie chart data and set the size scale to be the total for each barn?

There's no add ranges option when adding diagrams to properties that I can see

1
  • shouting into the void here, but I tried converting to longform which was not the move because temporal controller will only display one variable. Using the expression sum("Horses observed", group_by:= "Barn", filter:= "Color"='Pinto') on longform data in the diagram editor retains the use of a single variable but shows up empty on the map.
    – Nadka
    Commented Jan 11, 2022 at 16:58

1 Answer 1

1

ALRIGHT so I figured out how to make pie charts which work in temporal controller as temporal controller itself does not support diagrams. The first step was to have the data in longform with one line per location per day. In the case of my dummy data, this would be:

Barn Pinto Black Date Total
A 1 2 2021-12-03 3
C 2 0 2021-12-03 2
C 1 0 2021-07-22 1
B 0 2 2021-04-16 2
C 0 0 2021-04-16 0

The next step is to use geometry generator. Every color or "slice" is one marker in geometry generator. In this case that would mean writing:

wedge_buffer(center:=$geometry,azimuth:=0,width:=("Pinto"*360)/"Total",outer_radius:=10)

and

wedge_buffer(center:=$geometry,azimuth:=("Pinto"*180/"Total")+("Black"*180/"Total"),width:=("Black"*360)/"Total",outer_radius:=10)

The azimuth for the first value is zero and later it is *180/Total for future wedges. The color which the generated geometry is responsible for is *180/Total, while values between are *360/Total to keep the wedges rotated in the correct location on the circle. For example, if I wanted to add a pie slice for white horses, the generated geometry would be calculated by:

wedge_buffer(center:=$geometry,azimuth:=("White"*180/"Total")+("Black"*360/"Total")+("Pinto"*180/"Total"),width:=("White"*360)/"Total",outer_radius:=10)

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.