![]() |
VOOZH | about |
One fascinating area of research uses GPS to track the 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
Dataset: official_datasets; used dataset β csv
Dependencies: Matplotlib, Pandas, Numpy, Cartopy, Shapely
Repository(Github): source code
(check the repository for the documentation of source code.)
Writeup: explanation(.pdf)
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 the 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"π figure_1_Eric's_trajectory
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 the x-axis will vary from 0 to 30 with 20 bins within them, linearly spaced. Lastly, we plot 2D speed in m/s along the x-axis and Frequency along the y-axis using the xlabel() and ylabel() functions respectively and plot the data using plt.show().
Output :
π figure_3_speed
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.
Output:
π figure_4_time_stamp
PART (4/5): Daily Mean Speed
We are going to visualize the 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.
Output:
π figure_5_mean.avg.speed_perdayPART (5/5): Cartographic View
In this last part, we are going to track the Birds over 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.
Output:
π figure_6_bird_cartographicResources :
1. edX - HarvardX - Using Python for Research
2. Python functions doc_I
3. Python functions doc_II