# Mount Eddy Trail Run

–Foxtail Pines Revisited
species distribution
modeling
GIS
maps
data
trail run
exercise
explore
Author

RJ Cody Markelz

Published

January 1, 2023

Foxtail Pine Cone Illustration

# Introduction

My partner and I recently revisited one the conifer species that occur in the Miracle Mile, but by trail running up to the top of Mount Eddy (9,037 ft; 2,754 m) in the Klamath Range. The final sub-alpine zone near the top of the mountain is a large grove of Foxtail Pine (Pinus balfouriana). I paid another visit to that same grove in another recent post, but did not go up to the higher elevations above 8000 ft.

``````library(tidyverse)
library(gpx)
library(rgbif)
library(data.table)
library(maps)``````

In-file the trail run gps data and make a data frame to use for plotting.

``````run <-  read_gpx('~/DATA/data/mount_eddy_trail_run.gpx')
summary(run)``````
``````          Length Class  Mode
routes    1      -none- list
tracks    1      -none- list
waypoints 1      -none- list``````
``````TrailRun1 <- as.data.frame(run\$routes)
TrailRun1\$Time <- as.numeric(row.names(TrailRun1))``````

Make a quick plot using the latitude and longitude coordinates.

``````TR_p1 <- ggplot() +
geom_point(data = TrailRun1, aes(x = Longitude, y = Latitude), color = 'black', size = 2) +
xlab("Longitude") + ylab("Latitude")
TR_p1``````

Take a look at the elevation profile of the run.

``````TR_p2 <- ggplot() +
geom_line(data = TrailRun1, aes(x = Time, y = Elevation), color = 'black', size = 2) +
xlab("Time (seconds)") + ylab("Elevation (m)")
TR_p2``````

We can also plot the run and false color it based on the elevation. We can pass this plot to the plot_gg() function in the rayshader package to make a 3D plot of the run. The code for that is not run on the website because it takes too long to render, so I am showing the rendered snapshot as an external image instead.

``````TR_p3 <- ggplot() +
geom_point(data = TrailRun1, aes(x = Longitude, y = Latitude, color = Elevation), size = 2) +
scale_color_continuous(limits=c(800,2800))
TR_p3``````

``````# Not run for website rendering purposes, but you should!
# plot_gg(TR_p3, width = 15, height = 15, multicore = TRUE, scale = 1000,
#         zoom = .7, theta = 10, phi = 20, windowsize = c(3000, 3000))
# Sys.sleep(0.2)
# render_snapshot(filename = "mt-eddy-run-elevation-plot3.png", clear = TRUE)``````

Using the Latitude and Longitude coordinates of the area we can make a general area polygon to be used for a GBIF species observation query to the public database.

``````norcal_geometry <- paste('POLYGON((-122.6 41.35, -122.35 41.35, -122.35 41.25, -122.4 41.25, -122.6 41.25, -122.6 41.35))')

mm_species <- c("pinus balfouriana") # can add multiple species here for larger query

foxtail_data <- occ_data(scientificName = mm_species, hasCoordinate = TRUE, limit = 10000,
geometry = norcal_geometry)
foxtail_data``````
``````Records found [51]
Records returned [51]
Args [hasCoordinate=TRUE, occurrenceStatus=PRESENT, limit=10000, offset=0,
scientificName=pinus balfouriana, geometry=POLYGON((-122.6 41.35, -122.35
41.35, -122.35 41.25, -122.4 41.25, -122.6 41.25, -122.6 41.35))]
# A tibble: 51 × 119
key    scien…¹ decim…² decim…³ issues datas…⁴ publi…⁵ insta…⁶ publi…⁷ proto…⁸
<chr>  <chr>     <dbl>   <dbl> <chr>  <chr>   <chr>   <chr>   <chr>   <chr>
1 39472… Pinus …    41.3   -122. cdc,c… 50c950… 28eb1a… 997448… US      DWC_AR…
2 40548… Pinus …    41.3   -122. cdc,c… 50c950… 28eb1a… 997448… US      DWC_AR…
3 39471… Pinus …    41.3   -122. cdc,c… 50c950… 28eb1a… 997448… US      DWC_AR…
4 39474… Pinus …    41.3   -122. cdc,c… 50c950… 28eb1a… 997448… US      DWC_AR…
5 39612… Pinus …    41.3   -122. cdc,c… 50c950… 28eb1a… 997448… US      DWC_AR…
6 39612… Pinus …    41.3   -122. cdc,c… 50c950… 28eb1a… 997448… US      DWC_AR…
7 39475… Pinus …    41.3   -122. cdc,c… 50c950… 28eb1a… 997448… US      DWC_AR…
8 39857… Pinus …    41.3   -122. cdc,c… 50c950… 28eb1a… 997448… US      DWC_AR…
9 38922… Pinus …    41.3   -122. cdc,c… 50c950… 28eb1a… 997448… US      DWC_AR…
10 39610… Pinus …    41.3   -122. cdc,c… 50c950… 28eb1a… 997448… US      DWC_AR…
# … with 41 more rows, 109 more variables: lastCrawled <chr>, lastParsed <chr>,
#   crawlId <int>, hostingOrganizationKey <chr>, basisOfRecord <chr>,
#   occurrenceStatus <chr>, taxonKey <int>, kingdomKey <int>, phylumKey <int>,
#   classKey <int>, orderKey <int>, familyKey <int>, genusKey <int>,
#   speciesKey <int>, acceptedTaxonKey <int>, acceptedScientificName <chr>,
#   kingdom <chr>, phylum <chr>, order <chr>, family <chr>, genus <chr>,
#   species <chr>, genericName <chr>, specificEpithet <chr>, taxonRank <chr>, …``````
``````foxtail_coords <- foxtail_data\$data[ , c("decimalLongitude", "decimalLatitude",
"individualCount", "occurrenceStatus", "coordinateUncertaintyInMeters",
"institutionCode", "references")]``````

Plot the observations on the California map to see the limited polygon sampled.

``````maps::map(database = "state", region = "california")
points(foxtail_coords[ , c("decimalLongitude", "decimalLatitude")], pch = ".", col = "red", cex = 3)``````

Plot all of the observations using ggplot for the zoomed in area.

``````foxtail_plot1  <- ggplot(foxtail_coords, aes(x=decimalLongitude, y = decimalLatitude)) +
geom_point(color='red') + labs(title = "MM Zone")
foxtail_plot1``````

Combine trail running and foxtail pine occurrence observations.

``````run_plot2 <- ggplot() +
coord_quickmap() +
geom_point(data = TrailRun1, aes(x = Longitude, y = Latitude), color = 'black') +
geom_point(data=foxtail_coords, aes(x = decimalLongitude, y = decimalLatitude), color = 'red') +
xlab("Longitude") + ylab("Latitude")
run_plot2``````