
- Python 3 Basic Tutorial
- Python 3 - Home
- What is New in Python 3
- Python 3 - Overview
- Python 3 - Environment Setup
- Python 3 - Basic Syntax
- Python 3 - Variable Types
- Python 3 - Basic Operators
- Python 3 - Decision Making
- Python 3 - Loops
- Python 3 - Numbers
- Python 3 - Strings
- Python 3 - Lists
- Python 3 - Tuples
- Python 3 - Dictionary
- Python 3 - Date & Time
- Python 3 - Functions
- Python 3 - Modules
- Python 3 - Files I/O
- Python 3 - Exceptions
Tracking bird migration using Python-3
In some Research works, Researchers uses GPS modules to track the animal behavior. They can track how they are travelling to different places in different time of a year etc.
In this example we use that kind of dataset to get an idea, how Birds are moving in different places. In this dataset there are the location details from GPS module are stored. The complete dataset is in CSV form. In that file, there are different fields. The first one is Bird Id, then date_time, Latitude, longitude and speed.
For this Task, we need some modules that can be used in Python codes.
We are using matplotlib, pandas, and cartopy modules. To install them into the Anaconda, please follow these commands. These will install some other important modules when it needs.
conda install -c conda-forge matplotlib conda install -c anaconda pandas conda install -c scitools/label/archive cartopy
At first we will plot the location using the latitude and longitude values. There are two birds in the dataset, so using two different colors, we can visualize the tracking locations
Example code
import pandas as pd from matplotlib import pyplot as plt df = pd.read_csv('bird_tracking.csv') cr = df.groupby('bird_id').groups cr_groups = df.groupby('bird_id') group_list = [] for group in cr: group_list.append(group) plt.figure(figsize=(7, 7)) #Create graph from dataset using the first group of cranes for group in group_list: x,y = cr_groups.get_group(group).longitude, cr_groups.get_group(group).latitude plt.plot(x,y, marker='o', markersize=2) plt.show()
Output

Now we can plot this tracking results on the actual Geographical Map to visualize the exact way, which is used by those birds.
Example code
import pandas as pd import cartopy.crs as ccrs import cartopy.feature as cfeature import matplotlib.pyplot as plt df = pd.read_csv("bird_tracking.csv") bird_id = pd.unique(birddata.bird_id) # Setup the projection to display the details into map projection = ccrs.Mercator() plt.figure(figsize=(7,7)) axes = plt.axes(projection=projection) axes.set_extent((-30.0, 25.0, 50.0, 10.0)) axes.add_feature(cfeature.LAND) axes.add_feature(cfeature.OCEAN) axes.add_feature(cfeature.COASTLINE) axes.add_feature(cfeature.BORDERS, linestyle=':') for id in bird_id: index = df['bird_id'] == id x = df.longitude[index] y = df.latitude[index] axes.plot(x,y,'.', transform=ccrs.Geodetic(), label=id) plt.legend(loc="lower left") plt.show()
Output

- Related Articles
- What is Migration?
- Satellite Tracking
- Bird Life Cycle
- Tracking Memory Usage in PHP
- Emerging Possibilities with Eye Tracking
- Best Bug/Defect Tracking Tools
- How to Block Email Tracking?
- The 5 Best Price Tracking Tools
- 20 Best Bug/Defect Tracking Tools
- Top 5 open source bug tracking system
- Know about device tracking for smart phones
- How does GPS tracking threaten our privacy?
- Tracking the Evolution of the Project Management
- Methods for tracking database schema changes in MySQL?
- Model object's history tracking in Django
