This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
Austin is a city known to have many local parks and wildlife trails. As part of Austin’s promise to continue to support and protect its local wildlife and forests, its financially assisting local tree planting projects. For this project, the data I downloaded was composed of all the projects from 2015 to 2017 in the Austin area.
The original data set, was provided by https://data.austintexas.gov/dataset/Community-Tree-Report-Funded-Projects/abmz-ex9c and includes: the name of the project, the year the project was completed, and the location (longitude and latitude in degrees) of the project.
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.1.3
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5 v purrr 0.3.4
## v tibble 3.1.6 v dplyr 1.0.7
## v tidyr 1.1.4 v stringr 1.4.0
## v readr 2.1.1 v forcats 0.5.1
## Warning: package 'ggplot2' was built under R version 4.1.3
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(leaflet)
## Warning: package 'leaflet' was built under R version 4.1.3
library(lubridate)
##
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
library(sf)
## Warning: package 'sf' was built under R version 4.1.3
## Linking to GEOS 3.9.1, GDAL 3.2.1, PROJ 7.2.1; sf_use_s2() is TRUE
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.
url_data <- read.csv("Community_Tree_Report_Funded_Projects.CSV")
str(url_data)
## 'data.frame': 675 obs. of 36 variables:
## $ UNIQUE_ID : int 1 2 3 4 5 6 7 8 9 10 ...
## $ PROJECT_NAME : chr "Wildfire Communication Study" "TreeFolks Education Program" "Project Learning Tree - Exploring the Urban Forest" "Boardwalk Benches" ...
## $ PROJECT_IMAGE : chr "https://dl.dropboxusercontent.com/s/z0capr3xtkakupz/Think%20Trees.png?raw=0" "https://dl.dropboxusercontent.com/s/z0capr3xtkakupz/Think%20Trees.png?raw=0" "https://dl.dropboxusercontent.com/s/w7df6u1oxdtw0ky/project%20learning%20tree.jpg?raw=0" "https://dl.dropboxusercontent.com/s/4zr6jtx3r39h3lc/boardwalk%20benches.jpg?raw=0" ...
## $ PROJECT_DESCRIPTION : chr "Education project to communicate wildfire issues associated with living in the Wildland-Urban Interface." "Education program for proper tree planting and care techniques, community engagement, citizen science, and volu"| __truncated__ "Hands-on workshop teaching students how to think about complex environmental issues using the Project Learning "| __truncated__ "Installation of wood benches on the Ann and Roy Butler Hike-and-Bike Trail at Lady Bird Lake." ...
## $ STATUS : chr "Complete" "Complete" "Complete" "Complete" ...
## $ ADDRESS : chr "" "" "805 N Capital of Texas Hwy" "1820 S Lakeshore Blvd" ...
## $ CITY : chr "Austin" "Austin" "Austin" "Austin" ...
## $ STATE : chr "TX" "TX" "TX" "TX" ...
## $ ZIP : int NA NA 78746 78741 NA NA 78703 78704 78745 78751 ...
## $ COUNTRY : chr "United States" "United States" "United States" "United States" ...
## $ LATITUDE : num 30.2 30.3 30.3 30.2 30.3 ...
## $ LONGITUDE : num -97.5 -97.5 -97.8 -97.7 -97.5 ...
## $ MAPPING : chr "Not Mapped" "Not Mapped" "Mapped" "Mapped" ...
## $ COUNCIL_DISTRICT : chr "(no district defined)" "(no district defined)" "10" "3" ...
## $ PLANTING_PRIORITY : chr "(not mapped)" "(not mapped)" "Lowest" "Moderate" ...
## $ PROJECT_CATEGORY_MAPPING : chr "Informing (Not Mapped)" "Informing (Not Mapped)" "Informing" "Inspiring" ...
## $ PROJECT_CATEGORY : chr "Informing" "Informing" "Informing" "Inspiring" ...
## $ PROJECT_SUBCATEGORY : chr "Education" "Education" "Education" "Art" ...
## $ TREE_INCHES_PLANTED_DISTRIBUTION: int NA NA NA NA NA NA NA NA NA NA ...
## $ TREES_CARED_FOR : int NA NA NA NA NA NA NA NA NA NA ...
## $ PEOPLE_TAUGHT : int NA NA NA NA NA NA NA NA NA NA ...
## $ PEOPLE_INSPIRED : num NA NA NA NA NA NA NA NA NA NA ...
## $ METRICS_SOURCE : chr "" "" "" "" ...
## $ PROJECT_YEAR : int 2017 2016 2017 2017 2017 2018 2017 2017 2015 2017 ...
## $ APPLICANT : chr "Texas State University" "TreeFolks" "Rosewood Arboriculture" "The Trail Foundation" ...
## $ RECIPIENT : chr "Texas State University" "TreeFolks" "Rosewood Arboriculture" "The Trail Foundation" ...
## $ RECIPIENT_TYPE : chr "Schools" "Non-Profit" "Business" "Non-Profit" ...
## $ FUNDING_CHANNEL : chr "Urban Forest Grant" "Urban Forest Grant" "Urban Forest Grant" "Urban Forest Grant" ...
## $ FUNDING_SOURCE : chr "Urban Forest Replenishment Fund" "Urban Forest Replenishment Fund" "Urban Forest Replenishment Fund" "Urban Forest Replenishment Fund" ...
## $ AMOUNT_SPENT : num 20110 50000 4368 58000 43954 ...
## $ PROJECT_HYPERLINK : chr "http://www.commstudies.txstate.edu/people/faculty/fox.html" "https://www.treefolks.org/" "https://www.facebook.com/events/1624698884214464" "https://thetrailfoundation.org/portfolio/boardwalk-benches/" ...
## $ RESOURCE_DOCUMENTS : chr "" "" "" "" ...
## $ CREATED_BY : chr "kinge" "kinge" "kinge" "haltera" ...
## $ CREATED_DATE : chr "6/14/2019 0:00" "6/14/2019 0:00" "6/14/2019 0:00" "6/26/2018 11:04" ...
## $ MODIFIED_BY : chr "haltera" "haltera" "haltera" "haltera" ...
## $ MODIFIED_DATE : chr "7/2/2020 0:00" "7/2/2020 0:00" "7/2/2020 0:00" "7/2/2020 0:00" ...
This data included years that range from 2015 to 2020, so I decided to include all the projects with in this time frame.
df <- url_data %>%
filter(`PROJECT_YEAR` <= (2020)) %>% select(c(`PROJECT_NAME`, `STATUS`, `PROJECT_YEAR`, LONGITUDE, LATITUDE)) %>%
arrange(desc(`PROJECT_YEAR`))
When reviewing the dataset, I decided to only focus my leaflet on the name of the specific conservation project and the year it was completed.
labels = paste(df$`PROJECT_NAME`, df$`PROJECT_YEAR`, sep ='<br> Year Occured: ')
Tree_Map <- df %>%
leaflet() %>%
addTiles() %>%
addMarkers(popup=df$`PROJECT_NAME` , clusterOptions=markerClusterOptions(), label = lapply(labels, htmltools::HTML))
## Assuming "LONGITUDE" and "LATITUDE" are longitude and latitude, respectively
## Warning in validateCoords(lng, lat, funcName): Data contains 1 rows with either
## missing or invalid lat/lon values and will be ignored
Tree_Map