The world’s leading publication for data science, AI, and ML professionals.

Foraging spots detection in Great Whale’s migration routes

Stop detection in Great Whale's tracking records with movingpandas

Data for Change

Image by the Author. Foraging Spot detection of Great Whales in middle latitudes
Image by the Author. Foraging Spot detection of Great Whales in middle latitudes

In this demo, I will explain how to detect Foraging Spots in Great Whale’s migration routes in North Atlantic Ocean. In the paper by Silva et al (2013) the authors explained that Great Whales remained foraging at middle latitudes for prolonged periods[1]. Here, we are going to pre-set parameters that can find the spots in these mentioned middle latitudes that refers relatively closer to the Azores Islands. In a first review, I published "Time-filter for Great Whale’s migration routes" where you can visualize the movement pattern of the Great Whale’s based on a year filter for this case 2009.

In the publication by Silva et al (2013) the authors used the State-space model (SSSM) to identify animal behavior. In this review, I am going to test a different method developed in the python library Movingpandas with parameters of Time and Search Radio. Indeed, the analysis resulted as expected, it detected the animal behavior as stops in the middle latitudes. Please note! The parameters for animal behavior are key and they must be provided by bio-experts. In my demos, I expressed my common sense for animal behavior due to my biological and ecological studies background but consider that I am an expert in Geospatial methodologies more than in biology.

FINAL DEMO HERE

The parameters used for this Foraging Spot detection analysis were between 5 minutes and 110 minutes, in search radio of 800m. If you want to review more analysis with different parameters you can refer to the articles Foraging spots in Blue Whales GPS tracking and Stop detection in Bird’s migration GPS tracks – Movingpandas & KeplerGl.

"This demo is the second part of the movement analysis of Great Whale’s migration routes in the North Atlantic Ocean. There are still more perspectives that need to be reviewed such as stop segmentation. In a third review I will publish a demo with stop segmentation analysis to confirm the Foraging behavior of Great Whales"

In the next map, you will see how the parameters settled (under my common sense) showed the Foraging Behavior of Great Whales in middle latitudes. The studies mentioned that in order to save energy for migration the Great Whales preferred to Forage near the Azores Islands [1].

Image by the Author. Foraging spots detected in middle latitudes if Great Whale's migration routes
Image by the Author. Foraging spots detected in middle latitudes if Great Whale’s migration routes

At the moment it is great to know that the algorithm is working and indeed represents what the experts in Great Whales are saying about their migration routes. But in a scientific view, it is always good to keep questioning and criticizing the results and not leave them as ground truth. That is why I will keep analyzing the Great Whale’s migration routes in a third demo related to Foraging spot segmentation to confirm the foraging behavior of Whales in a more critical and visual way.

"If you are interested in animal behavior analytics there is software in development that can assist animal tracking studies. Take a look at Wildlife Tracker"

The analysis of animal behavior is a great approach for decision-making in Protected Areas management. It helps to answer the questions such as: What are the suitable limits for the Protected Area? Why we must protect the specified extent? What regulation of fishery must we regulate in the protected area?

DATA

The dataset used in this Demo corresponds to Azores Great Whales Satellite Telemetry Program. It can be found in Movebank and it is under license Creative Commons Attribution Non-commercial.

PRACTICE

Please be aware that this analysis corresponds to a second part of the already published Time-filter for Great Whale’s migration routes. So you may need to refer to the same names but either way you can do it by following this text.

First, we import the libraries

import pandas as pd
import geopandas as gpd
import movingpandas as mpd
from shapely.geometry import Point
from datetime import datetime, timedelta
from keplergl import KeplerGl

Then, we read the dataset

fp = r'data/azores_great_whales.geojson'
geodata = gpd.read_file(fp, driver='GeoJSON')

We prepare the geodata table

# preparing data
geodata['t'] = pd.to_datetime(geodata['timestamp'])
geodata = geodata.set_index('t')
# setting individuals
geodata['id_whale'] = ['w'+str(idwhale) for idwhale in geodata['ind_ident'].to_list()]
# time attributes
geodata['year'] = geodata.index.year
geodata['month'] = geodata.index.month

We prepare a geostopstable that contains the subset of 2019 we want

# prepare tables for visualization
geostops = geodata[['timestamp', 'long', 'lat','id_whale', 'year', 'geometry']]
subset = [2009]
geostops = geostops.loc[geostops['year'].isin(subset)]
geostops['year_id'] = ['Year '+str(year) for year in geostops['year'].to_list()]

In this part, we define the function that gives back the Foraging Stops based on parameters minutes and a search radio in km

def get_stop_point_traj_collection(moving_df, traject_id_column, Minutes, searchradio):

 all_stop_points = gpd.GeoDataFrame()

 # create a traj collection with movingpandas
 traj_collection = mpd.TrajectoryCollection(moving_df, traject_id_column)

 for i in range(len(traj_collection)):
 # create a stop detector
 detector = mpd.TrajectoryStopDetector(traj_collection.trajectories[i])

 # stop points
 stop_points = detector.get_stop_points(min_duration=timedelta(minutes=Minutes), max_diameter=searchradio)

 # add ID
 stop_points['tag_id'] = [tag.split('_')[0] for tag in stop_points.index.to_list()]

 all_stop_points= all_stop_points.append(stop_points)

 return all_stop_points

Now we apply the function with geostopstable

whale_stops = get_stop_point_traj_collection(geostops, 'id_whale', 5, 800)

Then, we calculate the duration of the time spent in Foraging Spots

# Duration of stops
whale_stops['duration_m'] = (whale_stops['end_time']-whale_stops['start_time']).dt.total_seconds()/60
# Between 5 and 110
whale_stops = whale_stops.loc[whale_stops['duration_m']<=110]
# remove datetime format for whale stops
whale_stops[['start_time', 'end_time']] = whale_stops[['start_time', 'end_time']].astype(str)

VISUALIZATION

For the visualization, we are using KeplerGl. We proceed to create an instance and adding the data.

# Create KeplerGl instance
m = KeplerGl(height=600)
m.add_data(whale_stops, 'Whale stops')

Finally, you save the map and configure it as you prefer using the time spent in Foraging Spots as I did. The column is duration_m

m.save_to_html(file_name='index.html')
Image by the Author. Foraging Spots in middle latitudes
Image by the Author. Foraging Spots in middle latitudes

CONCLUSION

As the demo has demonstrated, the algorithm is detecting foraging spots in middle latitudes considering that parameters characterize the foraging behavior of Great Whales. This is not a ground truth it may really need to be analyzed by experts in the marine biology field. This is only an exercise that shows how to use this algorithm.

RECOMMENDATION

When you are using this algorithm make tests. The variation in the parameters can give outcomes in different locations so you may need to really observe and define the proper parameters by critic view. As I suggested before, it would be suitable to test this algorithm with experts in the marine biology field. However, by observing the moves in the trajectory you can already know if the giant mammal is looking around for food or having straight moves so it is good guidance.


If you have further questions or need help in your analysis or in your projects you can find me in my personal profile on LinkedIn.

REFERENCES

[1] Silva MA, Prieto R, Jonsen I, Baumgartner MF, Santos RS (2013). "North Atlantic Blue and Fin Whales Suspend Their Spring Migration to Forage in Middle Latitudes: Building up Energy Reserves for the Journey? PLoS ONE 8(10): e76507. https://doi.org/10.1371/journal.pone.0076507


Related Articles