The data for this example is taken from the LifeWatch INBO project. Several datasets have been released as part of this project. We will use a small dataset that consists of migration data for three seagulls named Eric, Niko, and Sunn. Official_datasets ; The dataset used — cs> “& Gt; The csv file contains eight columns and contains variables such as latitude, longitude, altitude, and timestamps. In this example, we will first load data, present some simple flight paths, track flight speed, learn about daytime, and much, much more.
Purpose: to track the movement of three seagulls, and exactly — Erica, Niko and Sanne
Dataset: official_datasets ; used dataset —
Dependencies: Matplotlib, Pandas, Numpy, Cartopy, Shapely
Repository (Github): source code
(check repository for documentation source code.)
Review: explanation (.pdf)
We will divide our case study into five parts:
1. Visualization of longitude and latitude data of gulls.
2. Visualize the change in the speed of the seagulls.
3. Visualize the time it takes seagulls to cover equal distances along the way.
4. Visualize the average daily speed of the gulls.
5. A cartographic view of the travel of seagulls.
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 render 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 the size of the figure to 7 x 7 and plot it using the plot () function. The parameters inside the plot () function, ie X, y and "b." Specifies longitude data along the x-axis (for x), latitude along y (for y), and b = blue, to use. = circles in the render.
Output: You must have all the dependencies.Install them using "pip install dependency_name"
PART (2/5 ): 2D speed versus frequency
In the second part of the case, we are going to visualize 2D speed and frequency for a seagull 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 speed [~ ind] parameters indicate that we will only include records for which ind! = True, bins = np.linspace (0,30,20) indicates that the cells on the x-axis will range from 0 to 30 with 20 cells within them being linearly spaced. Finally, we plot the 2D velocity 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 ().
PART (3/5): time and date strong >
The third part is related to the date and time. We`re going to visualize the time (in days) it takes Eric to travel constant distances throughout his journey. If it covers equal distances in an equal amount of time, then the elapsed time and observation The 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"))
“& gt; & gt; & gt; datetime.datetime.today () ", returns the current date (yy-mm-dd) and time (h: m: s).
"& gt; & gt; & gt; date_str [: — 3] ”, cuts / removes coordinated UTC +00 timestamps.
"& gt; & gt; & gt; datetime.datetime.strptime (date_str [: — 3], "% Y-% m-% d% H:% M:% S") ", the timestamp strings from date_str are converted to a datetime object to work on"% Y-% m-% d% H:% M:% S "— this format is year-month-date and hour-minute-second.
PART (4/5): Average Daily Speed
We are going to visualize the average daily speed of Eric the seagull for the total number of days on 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 birds above the map.
import cartopy.crs as ccrs import cartopy.feature as cfeature
These modules are important for displaying data.
ax.add_feature (cfeature.LAND) ax. add_feature (cfeature.OCEAN) ax.add_feature (cfeature.COASTLINE) ax.add_feature (cfeature.BORDERS, linestyle = `:`)
We will add significant physical features to the map.
This article is courtesy of Amartya Ranjan Saikia . If you are as Python.Engineering and would like to contribute, you can also write an article using contribute.python.engineering or by posting an article contribute @ python.engineering. See my article appearing on the Python.Engineering homepage and help other geeks.
Please post comments if you find anything wrong or if you would like to share more information on the topic discussed above.