This article provides a comprehensive guide on conducting spatial analysis using R in Julius. It covers the process of importing geospatial data and visualization of longitude and latitude coordinates.
The study of animal movement is widely used in biological practices to understand ecological dynamics, species behavior, and habitat use. Spatial data, comprising geographic coordinates and temporal information, allows for accurate tracking of species as they transverse environments. This information can aid in the recovery of endangered species by providing insights into migration patterns, home ranges, and interactions between biotic and abiotic factors.
Spatial data analysis is not limited to the biological sector. Many other sciences use spatial data for various applications. For example, archeologists use GPS coordinates to map out dig sites and locate features. In public health, spatial data can be used to track the spread of disease and identify “hotspots” in a community. For infrastructure and development, spatial data provides detailed information about terrain and structures, aiding in planning and development of roads, bridges, and other infrastructure.
In this tutorial, we will use the “animal_movement_data-Google Sheets” dataset, which contains information collected by ecologists when analyzing animal movement patterns. Our sample data tracks the movements of three bear species post-release from a wildlife rehabilitation center in Pennsylvania. For each species, 100 points were collected, resulting in 300 observations over a month-long period (N= 300). The dataset can be accessed here.
This walkthrough will be done using R, however you can also perform the analysis in Julius using Python by switching the code runtime environment toggle in the top right of the chat interface.
To connect a dataset, you can either select the paperclip icon in the input bar to upload your data as a file, or you can also paste in a link to a publicly-shared Google Sheet. In this case, we are going to connect to a Google Sheet containing the animal movement spatial data.
Prompt: Load dataset from: animal_movement_data - Google Sheets
The above screenshot shows our imported dataset from the Google Sheets URL.
To identify the bear species in the “bears” column, we can use the unique() function to extract the different species of bears in our dataset.
Prompt: Name the different bear species in this dataset
Above shows the 3 unique species we have extracted from the dataset using the unique() function:
a. Black Bear
b. Grizzly Bear
c. Polar Bear
The next step is to plot a baseline map of the state of Pennsylvania.
Prompt: Create a map of Pennsylvania using the library(maps) function and load it.
Code output:
In the above screenshot, we can see that Julius has imported the baseline map of Pennsylvania using the ‘maps’ library. The ‘maps’ library can be used to import various continents, countries, states, and provinces.
Our next step is to overlay the coordinates of the three species onto the map of Pennsylvania.
Prompt: Layer all three species latitude and longitude coordinates in the dataset onto the map of Pennsylvania we created.
Code output:
In the above screenshot, you can see that Julius has plotted the coordinates for each species of bear on a map of Pennsylvania. Now we can examine different metrics to identify potential trends in the movement data, such as home range and density of points within a given area.
In spatial analysis, home range refers to the area a species inhabits or frequents. It can represent the spatial extent a species occupies while performing daily activities.
For this analysis, we will use the minimum convex polygon (MCP) method to encompass all recorded locations of each species, revealing if any of the home ranges intersect. We can also calculate the area inside the polygon in square kilometers.
Prompt 1: Can we calculate the home ranges of each bear species using the minimum convex polygon (MCP) method and then overlay them onto the map please?
Code Output:
Above we can see the different home ranges between all three species. Next, we will calculate the square kilometers for each home range.
Prompt 2: Please calculate the home range areas in square kilometers using the degrees to square kilometers conversion factor.
Note: the conversion factor we use gives us a more generalized estimate.
Code Output:
Above are the square kilometers for each home range we calculated. Examining these results, we can conclude that the Grizzly Bear has the largest home range.
A heatmap is a graphical representation of data that displays distribution and intensity of data points. Here, we can use a heatmap to identify the areas frequented most by each bear species. We will use the scale_fill_viridis_c() function, known to be color blind friendly, with a scale ranging from dark blue/purple to green/yellow, where dark blue represents lower density and yellow represents higher density.
Prompt: Please filter longitude and latitude coordinates for each bear species. Plot Grizzly Bears onto a map of Pennsylvania. Then on a second map plot polar bears. On a third map plot black bears. For each separate map, create a heatmap for each bear species
Note: I wanted to display the density for each bear species separately, but you can collate them together.
Code Output:
Above we can see the different heatmaps for each species of bear in the dataset. This information can be used to infer where the species spends most of their time.
This use case demonstrates how to analyze animal movement data to assess spatial distribution patterns of different bear species within a designated area. We employed the ‘maps’ library function to import the state of Pennsylvania, used the ‘sf’ library to outline the home ranges of each species of bear, and then used ggplot2 to generate heatmaps to visualize the preferred habitat area for each species based on the intensity of points.
Julius serves as an invaluable resource in the creation and analysis of spatial data. Its capabilities enable the generation of complex visualizations with ease; users need only prompt in plain language to create beautiful graphical representations. This allows researchers and others to delve deeper into understanding spatial dataset without the hassle of coding. Julius is a great resource for all of your spatial data analysis needs!