Note: This will be the report part of the assignment.

Most Visited National Parks in 2022 In order to visualize the locations of the most visited National Parks last year , I needed two sets of data: 1. A list of the most visited National Parks from the NPS website: https://irma.nps.gov/Stats/SSRSReports/National%20Reports/Annual%20Park%20Ranking%20Report%20(1979%20-%20Last%20Calendar%20Year) 2. A list of their coordinates

In this case, “Visits” refers to recreational visits which means the visit is not traveling through the park as a means of commuting and is not in the park for NPS work-related purposes.

I was able to find a list of coordinates at this website: https://www.latlong.net/category/national-parks-236-42.html This did not include all the National Parks on the list, so I crossreferenced and removed the parks from the NPS’s list to only include the ones I had coordinates for. This left me with 34 parks. I wanted the most visited parks to be the darkest in color and I wanted to be able to see their ranking when I hovered but the actual number of visits when I clicked.

From this map, I can see the most visited parks as a whole were in the Intermountain region. The least visited parks were in the Alaska region. This may be because is not as easy to access this area of the US. Along the same lines, the most visited National Park is the Great Smoky Mountains. This could be because it is very easy to drive through as it is a main road.

ROMO Monthly Visitors I then wanted to visualize the number of monthly visits by year of Rocky Mountain National Park. I used the information from the NPS.gov website: https://irma.nps.gov/Stats/SSRSReports/Park%20Specific%20Reports/Recreation%20Visitors%20By%20Month%20(1979%20-%20Last%20Calendar%20Year)?Park=ROMO

By hovering over it, you can see the exact number of visitors. From this visualization we can the busiest time of year over the last 40 years have been the summer months, specifically July. There is severe dropoff in September. This may be because students are returning to school.There is an uptick in October before dropping back off in November. October in the Rocky Mountain is likely visited due to the changing colors of the leaves and elk mating season. Another interesting to note is the dark green cell in April. This is the lowest number on the whole heatmap. This was the start of stay-at-home orders at the beginning of the COVID-19 pandemic.

library(leaflet)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
park_rankings <- read.csv("/Users/mpolser/Library/CloudStorage/GoogleDrive-mpolser@umd.edu/My Drive/Personal/ANTH/ANTH630/Final Project/csv/rank_np_coord.csv")

The data I’m using does not include all the ranked parks because I couldn’t get all the gps coordinates. So I used 34 parks that I could get the coordinates for.

I’m not sure if it’s how I saved the CSV file but it’s acting as if all the empty rows after my data are part of my dataset. So I’m going to reset the object using the head function.

park_rankings <- head(park_rankings, 34)

#color palette for the range of "Recreation_Visits"
colors <- colorNumeric(palette = "Greens", domain = park_rankings$Recreation_Visits)

#I want to see the park name and rank when I hover but when I click, I want to see the park, rank, and number of visits

Park_Map <- leaflet(data = park_rankings) %>% 
  addTiles() %>% 
  addCircleMarkers(
    ~Longitude, ~Latitude,
    fillColor = ~colorQuantile("Greens", Recreation_Visits, n = 15)(Recreation_Visits),
    fillOpacity = 0.8,
    radius = 10,
    stroke = FALSE,
    popup = ~paste("Park: ", Park, "<br>",
                  "Rank: ", Rank, "<br>",
                  "Recreation Visits: ", Recreation_Visits, "<br>"),
    label = lapply(park_rankings$Park, 
                   function(x) {
                     labels = paste0(x, "\nRank: ", park_rankings[park_rankings$Park == x,]$Rank)})
  ) %>%
  addLegend(
  "bottomright", 
  pal = colors, 
  values = park_rankings$Recreation_Visits, 
  title = "Recreation Visits", 
  opacity = 1)
## Warning in RColorBrewer::brewer.pal(max(3, n), palette): n too large, allowed maximum for palette Greens is 9
## Returning the palette you asked for with that many colors
Park_Map
#I could not get the label to break. I know we had trouble in class with this and I didn't know of anyone who figured it out. Google fails me as well. I added the package "htmltools" and tried the code below (instead of rank I was using recreation visits) but to no avail.

#labels <- paste(
 # "<strong>", park_rankings$Park,
  #"</strong><br>Recreation_Visits:", park_rankings$Recreation_Visits) %>%
  #lapply(htmltools::HTML)

#labels <- sprintf(
 # "<strong>%s</strong><br/>Park: %s",
  #park_rankings$Rank, park_rankings$Recreation_Visits) %>%
  #lapply(htmltools::HTML)

I also had issues with the color palette. The warning was that n is too large, and the Greens palette can only return 9 shades. but I was okay with that.

Heatmap

library(ggplot2)
library(RColorBrewer)

ROMO_data <- read.csv("/Users/mpolser/Library/CloudStorage/GoogleDrive-mpolser@umd.edu/My Drive/Personal/ANTH/ANTH630/Final Project/csv/ROMO Vis by Month.csv")

# Convert data to long format
ROMO_long <- reshape2::melt(ROMO_data, id.vars = "Year", variable.name = "Month")

names(ROMO_long)[names(ROMO_long) == "value"] <- "Visitor_Count"

# Create the heatmap using ggplot2
ROMO_heatmap <- ggplot(ROMO_long, aes(x = Month, y = Year, fill = Visitor_Count)) +
  geom_tile() +
  scale_fill_gradientn(colours = rev(brewer.pal(11, "PiYG")), na.value = "grey90") +
  labs(x = "Month", y = "Year", fill = "Number of Visitors") +
  ggtitle("Rocky Mountain National Park Monthly Visitors by Year") +
  labs(caption = "Source: NPS.gov") +
  theme(plot.title = element_text(hjust = 0.5))

ROMO_heatmap

library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
ROMO_heatmap_interactive <- ggplotly(ROMO_heatmap, tooltip = c("Month", "Year", "Visitor_Count")) %>%
  layout(annotations = list(
      text = "Source: NPS.gov",
      x = 0,
      y = -0.1,
      showarrow = FALSE,
      xref = "paper",
      yref = "paper",
      xanchor = "left",
      yanchor = "top",
      font = list(size = 12)
    ),
    xaxis = list(
      title = list(text = "Month", standoff = 20)
    )
  )



ROMO_heatmap_interactive