Analyzing data from Movebank¶
[1]:
import movekit as mkit
Read data input¶
[2]:
data = mkit.read_movebank('datasets/Mangabey_monkeys_in_Uganda.csv')
data.head()
[2]:
time | animal_id | x | y | event-id | visible | location-long | location-lat | behavioural-classification | comments | study-specific-measurement | sensor-type | individual-taxon-canonical-name | tag-local-identifier | study-name | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1337 | 1972-05-01 05:15:00 | BT | 206205.00004 | 61229.999999 | 1215038324 | True | 30.360556 | 0.553375 | ? | NaN | SUBADULT | natural-mark | Lophocebus albigena | BT | Mangabey monkeys in Uganda (data from Waser 1975) |
0 | 1972-05-01 05:15:00 | KT | 206220.00004 | 61219.999999 | 1215038318 | True | 30.360691 | 0.553285 | ? | NaN | ADULT | natural-mark | Lophocebus albigena | KT | Mangabey monkeys in Uganda (data from Waser 1975) |
710 | 1972-05-01 05:15:00 | LN | 206210.00004 | 61234.999999 | 1215038323 | True | 30.360601 | 0.553420 | ? | NaN | ADULT | natural-mark | Lophocebus albigena | LN | Mangabey monkeys in Uganda (data from Waser 1975) |
9637 | 1972-05-01 05:15:00 | M Group | 206209.00004 | 61220.499999 | 1099185632 | True | 30.360592 | 0.553289 | NaN | 9.0 | NaN | natural-mark | Lophocebus albigena | M Group | Mangabey monkeys in Uganda (data from Waser 1975) |
2148 | 1972-05-01 05:45:00 | HK | 206235.00004 | 61574.999999 | 1215038325 | True | 30.360824 | 0.556493 | FEED:DS:FRUIT | NaN | ADULT | natural-mark | Lophocebus albigena | HK | Mangabey monkeys in Uganda (data from Waser 1975) |
Basic Data Analysis¶
For further data analysis functions of movekit
please refer to the other example notebooks or the documentation. It is important to preprocess the data from Movebank, as the data often contains duplicates which can lead to problems in further analysis steps.
[10]:
data = mkit.preprocess(data, interpolation = True, date_format = True) # important to indicate the date format of time by setting date_format=True when applying interpolation
data.head()
Total number of missing values = 14437
comments 9637
behavioural-classification 2400
study-specific-measurement 2400
time 0
animal_id 0
x 0
y 0
event-id 0
visible 0
location-long 0
location-lat 0
sensor-type 0
individual-taxon-canonical-name 0
tag-local-identifier 0
study-name 0
dtype: int64
[10]:
time | animal_id | x | y | event-id | visible | location-long | location-lat | behavioural-classification | comments | study-specific-measurement | sensor-type | individual-taxon-canonical-name | tag-local-identifier | study-name | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1337 | 1972-05-01 05:15:00 | BT | 206205.00004 | 61229.999999 | 1215038324 | True | 30.360556 | 0.553375 | ? | NaN | SUBADULT | natural-mark | Lophocebus albigena | BT | Mangabey monkeys in Uganda (data from Waser 1975) |
0 | 1972-05-01 05:15:00 | KT | 206220.00004 | 61219.999999 | 1215038318 | True | 30.360691 | 0.553285 | ? | NaN | ADULT | natural-mark | Lophocebus albigena | KT | Mangabey monkeys in Uganda (data from Waser 1975) |
710 | 1972-05-01 05:15:00 | LN | 206210.00004 | 61234.999999 | 1215038323 | True | 30.360601 | 0.553420 | ? | NaN | ADULT | natural-mark | Lophocebus albigena | LN | Mangabey monkeys in Uganda (data from Waser 1975) |
9637 | 1972-05-01 05:15:00 | M Group | 206209.00004 | 61220.499999 | 1099185632 | True | 30.360592 | 0.553289 | NaN | 9.0 | NaN | natural-mark | Lophocebus albigena | M Group | Mangabey monkeys in Uganda (data from Waser 1975) |
2148 | 1972-05-01 05:45:00 | HK | 206235.00004 | 61574.999999 | 1215038325 | True | 30.360824 | 0.556493 | FEED:DS:FRUIT | 10.0 | ADULT | natural-mark | Lophocebus albigena | HK | Mangabey monkeys in Uganda (data from Waser 1975) |
[13]:
data = mkit.extract_features(data)
data.head()
Extracting all absolute features: 100%|██████████| 100.0/100 [00:03<00:00, 32.24it/s]
[13]:
time | animal_id | x | y | distance | direction | turning | average_speed | average_acceleration | stopped | ... | visible | location-long | location-lat | behavioural-classification | comments | study-specific-measurement | sensor-type | individual-taxon-canonical-name | tag-local-identifier | study-name | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1972-05-01 05:15:00 | BT | 206205.00004 | 61229.999999 | 0.0 | (0.0, 0.0) | 0.0 | 144.909354 | -6.750061 | 0 | ... | True | 30.360556 | 0.553375 | ? | 0.0 | SUBADULT | natural-mark | Lophocebus albigena | BT | Mangabey monkeys in Uganda (data from Waser 1975) |
1 | 1972-05-01 05:15:00 | KT | 206220.00004 | 61219.999999 | 0.0 | (0.0, 0.0) | 0.0 | 89.757240 | 8.491764 | 0 | ... | True | 30.360691 | 0.553285 | ? | 0.0 | ADULT | natural-mark | Lophocebus albigena | KT | Mangabey monkeys in Uganda (data from Waser 1975) |
2 | 1972-05-01 05:15:00 | LN | 206210.00004 | 61234.999999 | 0.0 | (0.0, 0.0) | 0.0 | 280.498911 | 3.702460 | 0 | ... | True | 30.360601 | 0.553420 | ? | 0.0 | ADULT | natural-mark | Lophocebus albigena | LN | Mangabey monkeys in Uganda (data from Waser 1975) |
3 | 1972-05-01 05:15:00 | M Group | 206209.00004 | 61220.499999 | 0.0 | (0.0, 0.0) | 0.0 | 41.606821 | -0.149840 | 0 | ... | True | 30.360592 | 0.553289 | 0 | 9.0 | 0 | natural-mark | Lophocebus albigena | M Group | Mangabey monkeys in Uganda (data from Waser 1975) |
4 | 1972-05-01 05:45:00 | HK | 206235.00004 | 61574.999999 | 0.0 | (0.0, 0.0) | 0.0 | 243.150166 | -7.612515 | 0 | ... | True | 30.360824 | 0.556493 | FEED:DS:FRUIT | 10.0 | ADULT | natural-mark | Lophocebus albigena | HK | Mangabey monkeys in Uganda (data from Waser 1975) |
5 rows × 21 columns
[7]:
#calculate for each animal the distance covered between 1972-5-1 and 1972-10-1 12:00:00
mkit.distance_by_time(data, '1972-5-1','1972-10-1 12:00:00')
[7]:
animal_id | distance | |
---|---|---|
0 | BB | 29292.196235 |
1 | BC | 32339.850273 |
2 | BR | 25428.128415 |
3 | BT | 56379.253280 |
4 | CH | 0.000000 |
5 | FB | 0.000000 |
6 | HK | 44779.676823 |
7 | JA | 0.000000 |
8 | JE | 42121.957235 |
9 | KT | 44881.459185 |
10 | LN | 36373.411270 |
11 | M Group | 69659.023543 |
12 | O | 48254.273757 |
13 | PB | 16140.353833 |
14 | RF | 55879.886570 |
15 | S | 17618.932566 |
16 | SK | 22967.788494 |
17 | TK | 49030.622798 |
Create interactive maps with the geodata¶
Using the geodata interactive maps can be created. By clicking on the marker points the animal_id and the time of each marker is displayed.
[3]:
# as the creation of the map is very time-confusing it is recommended to select a subsample of animals for which the map is created.
mkit.plot_geodata(data, animal_list=["BT", "KT"])
Plotting geo data for specified animals: 100%|██████████| 2/2 [00:00<00:00, 4.34it/s]
[3]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Additionally the movement of individual animals can be retraced by including movement lines in between the different markers.
[4]:
# each movement line has a tooltip to follow the sequence of movement (here animal "JA" for example starts in south west)
movement_map = mkit.plot_geodata(data, animal_list=["JA"], movement_lines=True)
movement_map
Plotting geo data for specified animals: 100%|██████████| 1/1 [00:00<00:00, 8.70it/s]
[4]:
Make this Notebook Trusted to load map: File -> Trust Notebook
The created maps can also be saved locally.
[10]:
#mkit.save_geodata_map(movement_map, "mymap.html")