One fascinating area of research uses GPS to track movements of animals. It is now possible to manufacture a small GPS device that is solar charged, so you don’t need to change batteries and use it to track flight patterns of birds.
The data for this case study comes from the LifeWatch INBO project. Several data sets have been released as part of this project. We will use a small data set that consists of migration data for three gulls named Eric, Nico, and Sanne. The official_datasets ; used dataset – csv“>csv file contains eight columns and includes variables like latitude, longitude, altitude, and time stamps. In this case study, we will first load the data, visualize some simple flight trajectories, track flight speed, learn about daytime and much, much more.
Aim: Track the movement of three gulls namely – Eric, Nico & Sanne
Dependencies: Matplotlib, Pandas, Numpy, Cartopy, Shapely
Repository(Github): source code
(check the repository for documentation of source code.)
We will divide our case study into five parts:
1. Visualizing longitude and latitude data of the gulls.
2. Visualize the variation of the speed of the gulls.
3. Visualize the time required by the gulls to cover equal distances over the journey.
4. Visualize the daily mean speed of the gulls.
5. Cartographic view of the journey of the gulls.
PART (1/5): Latitude and Longitude
In this part, we are going to visualize the location of the birds. We are going to plot latitude and longitude along y and x-axis respectively and visualize the location data present in the csv file.
plt.figure(figsize = (7,7)) plt.plot(x,y,"b.")
We use the matplotlib function, figure() to initialize size of the figure as 7 x 7 and plot it using the plot() function.The parameters inside the function plot() i.e x, y and “b.” are specifying to use longitude data along x axis(for x), latitude along y(for y) and b=blue, . = circles in the visualization.
Output : You must have all the dependencies.Install them using "pip install dependency_name"
PART (2/5): 2D Speed Vs Frequency
In this second part of the case study, we are going to visualize 2D speed vs Frequency for the gull named “Eric”.
ind = np.isnan(speed) plt.hist(speed[~ind], bins = np.linspace(0,30,20), normed=True) plt.xlabel(" 2D speed (m/s) ") plt.ylabel(" Frequency ") plt.show()
The parameters speed[~ind] indicates that we will include only those entries for which ind != True, bins=np.linspace(0,30,20) indicates the bins along x axis will vary from 0 to 30 with 20 bins within them, linearly spaced.Lastly, we plot 2D speed in m/s along x-axis and Frequency along y-axis using the xlabel() and ylabel() functions respectively and plot the data using plt.show().
PART (3/5): Time and Date
The third part is associated with date and time.We are going to visualize the time(in days) required by Eric to cover constant distances through his journey.If he covers equal distances in an equal amount of time, then the Elapsed time vs Observation curve will be linear.
for k in range(len(birddata)): timestamps.append(datetime.datetime.strptime(birddata.date_time.iloc[k][:-3], "%Y-%m-%d %H:%M:%S"))
“>>>datetime.datetime.today()”, returns the current Date (yy-mm-dd) & time (h:m:s).
“>>>date_str[:-3]”, slices/removes the UTC +00 coordinated time stamps.
“>>>datetime.datetime.strptime(date_str[:-3], “%Y-%m-%d %H:%M:%S”)” ,the time-stamp strings from date_str are converted to datetime object to be worked upon. “%Y-%m-%d %H:%M:%S” is the Year-Month-Date and Hour-Minute-Second format.
PART (4/5): Daily Mean Speed
We are going to visualize daily mean speed of the gull named “Eric” for the total number of days of recorded flight.
enumerate() - is one of the built-in Python functions. It returns an enumerated object. In our case, that object is a list of tuples (immutable lists), each containing a pair of count/index and value.
PART (5/5): Cartographic View
In this last part, we are going to track the Birds oover a map.
import cartopy.crs as ccrs import cartopy.feature as cfeature
These modules are important for mapping data.
ax.add_feature(cfeature.LAND) ax.add_feature(cfeature.OCEAN) ax.add_feature(cfeature.COASTLINE) ax.add_feature(cfeature.BORDERS, linestyle=':')
We add the salient physical features of a map.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.