QUESTION 1

library(sf)
## Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE
library(tmap)
## Breaking News: tmap 3.x is retiring. Please test v4, e.g. with
## remotes::install_github('r-tmap/tmap')
library(tigris)
## To enable caching of data, set `options(tigris_use_cache = TRUE)`
## in your R script or .Rprofile.
library(tidycensus)

census_api_key("4156b3413d433f2f6803ff4b60faa2a8bb579da2",overwrite ="TRUE")
## To install your API key for use in future sessions, run this function with `install = TRUE`.
var <- c(poptotal='B03002_001E', 
         hispanic='B03002_012E') 

BOULDER <- get_acs(geography = "tract", variables = var, count= "Boulder",
                   state = "CO" ,output="wide", year = 2021, geometry = TRUE)
## Getting data from the 2017-2021 5-year ACS
## Downloading feature geometry from the Census website.  To cache shapefiles for use in future sessions, set `options(tigris_use_cache = TRUE)`.
##   |                                                                              |                                                                      |   0%  |                                                                              |=                                                                     |   2%  |                                                                              |==                                                                    |   2%  |                                                                              |===                                                                   |   4%  |                                                                              |===                                                                   |   5%  |                                                                              |====                                                                  |   6%  |                                                                              |=====                                                                 |   7%  |                                                                              |======                                                                |   9%  |                                                                              |=======                                                               |  10%  |                                                                              |========                                                              |  12%  |                                                                              |=========                                                             |  12%  |                                                                              |==========                                                            |  14%  |                                                                              |===========                                                           |  15%  |                                                                              |===========                                                           |  16%  |                                                                              |============                                                          |  17%  |                                                                              |=============                                                         |  19%  |                                                                              |===============                                                       |  21%  |                                                                              |================                                                      |  22%  |                                                                              |=================                                                     |  24%  |                                                                              |=================                                                     |  25%  |                                                                              |==================                                                    |  26%  |                                                                              |===================                                                   |  28%  |                                                                              |====================                                                  |  29%  |                                                                              |=====================                                                 |  30%  |                                                                              |======================                                                |  31%  |                                                                              |=======================                                               |  33%  |                                                                              |========================                                              |  35%  |                                                                              |=========================                                             |  35%  |                                                                              |==========================                                            |  37%  |                                                                              |===========================                                           |  38%  |                                                                              |===========================                                           |  39%  |                                                                              |============================                                          |  40%  |                                                                              |=============================                                         |  42%  |                                                                              |==============================                                        |  42%  |                                                                              |===============================                                       |  44%  |                                                                              |================================                                      |  45%  |                                                                              |=================================                                     |  47%  |                                                                              |==================================                                    |  49%  |                                                                              |===================================                                   |  50%  |                                                                              |====================================                                  |  51%  |                                                                              |=====================================                                 |  53%  |                                                                              |======================================                                |  54%  |                                                                              |=======================================                               |  56%  |                                                                              |========================================                              |  58%  |                                                                              |=========================================                             |  59%  |                                                                              |==========================================                            |  60%  |                                                                              |===========================================                           |  62%  |                                                                              |============================================                          |  63%  |                                                                              |=============================================                         |  65%  |                                                                              |===============================================                       |  66%  |                                                                              |================================================                      |  69%  |                                                                              |=================================================                     |  70%  |                                                                              |=================================================                     |  71%  |                                                                              |==================================================                    |  72%  |                                                                              |====================================================                  |  74%  |                                                                              |=====================================================                 |  76%  |                                                                              |======================================================                |  78%  |                                                                              |========================================================              |  79%  |                                                                              |=========================================================             |  81%  |                                                                              |==========================================================            |  83%  |                                                                              |===========================================================           |  84%  |                                                                              |=============================================================         |  87%  |                                                                              |==============================================================        |  88%  |                                                                              |===============================================================       |  90%  |                                                                              |================================================================      |  92%  |                                                                              |=================================================================     |  93%  |                                                                              |==================================================================    |  95%  |                                                                              |===================================================================   |  95%  |                                                                              |====================================================================  |  97%  |                                                                              |===================================================================== |  99%  |                                                                              |======================================================================| 100%
BOULDER$B03002_001M<- NULL

BOULDER$B03002_012M<- NULL

BOULDER$hispanic_pct <- BOULDER$hispanic/BOULDER$poptotal

tmap_mode("plot")
## tmap mode set to plotting
tm_shape(BOULDER) +
  tm_polygons(col = "hispanic_pct") + 
  tm_layout(legend.position = c("center", "bottom"),  # Center the legend at the bottom of the map
          legend.outside = TRUE,  # Place the legend outside the map
          legend.outside.position = "right")+
  tm_compass(type = "8star", position = c("left","top"))+  
  tm_scale_bar(position = c("right", "top"))

QUESTION 2

Boulder_Playground_Sites <- st_read('C:/Users/adrian.gallegos/OneDrive - BASIS.ed/Desktop/FALL UTSA/PROJECT 2/Playground_Sites_Points/Playground_Sites_Points.shp')
## Reading layer `Playground_Sites_Points' from data source 
##   `C:\Users\adrian.gallegos\OneDrive - BASIS.ed\Desktop\FALL UTSA\PROJECT 2\Playground_Sites_Points\Playground_Sites_Points.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 89 features and 40 fields
## Geometry type: POINT
## Dimension:     XY
## Bounding box:  xmin: 3057157 ymin: 1230282 xmax: 3092316 ymax: 1274113
## Projected CRS: NAD83(HARN) / Colorado North (ftUS)
Boulder_Playground_Sites<-st_transform(Boulder_Playground_Sites,crs = 4326)

Boulder_ct <-tracts(state = "CO", county = "Boulder",cb=T)
## Retrieving data for the year 2022
##   |                                                                              |                                                                      |   0%  |                                                                              |==                                                                    |   3%  |                                                                              |====                                                                  |   6%  |                                                                              |=====                                                                 |   7%  |                                                                              |======                                                                |   8%  |                                                                              |=======                                                               |  10%  |                                                                              |========                                                              |  12%  |                                                                              |=========                                                             |  13%  |                                                                              |===========                                                           |  15%  |                                                                              |============                                                          |  17%  |                                                                              |=============                                                         |  18%  |                                                                              |=============                                                         |  19%  |                                                                              |===============                                                       |  22%  |                                                                              |================                                                      |  23%  |                                                                              |=================                                                     |  25%  |                                                                              |==================                                                    |  26%  |                                                                              |===================                                                   |  27%  |                                                                              |====================                                                  |  29%  |                                                                              |=====================                                                 |  30%  |                                                                              |======================                                                |  31%  |                                                                              |=======================                                               |  32%  |                                                                              |========================                                              |  35%  |                                                                              |=========================                                             |  35%  |                                                                              |==========================                                            |  37%  |                                                                              |===========================                                           |  38%  |                                                                              |===========================                                           |  39%  |                                                                              |============================                                          |  40%  |                                                                              |=============================                                         |  42%  |                                                                              |==============================                                        |  43%  |                                                                              |===============================                                       |  44%  |                                                                              |================================                                      |  46%  |                                                                              |=================================                                     |  47%  |                                                                              |==================================                                    |  49%  |                                                                              |===================================                                   |  50%  |                                                                              |====================================                                  |  51%  |                                                                              |=====================================                                 |  52%  |                                                                              |======================================                                |  54%  |                                                                              |======================================                                |  55%  |                                                                              |=======================================                               |  56%  |                                                                              |=========================================                             |  58%  |                                                                              |=========================================                             |  59%  |                                                                              |==========================================                            |  60%  |                                                                              |===========================================                           |  62%  |                                                                              |============================================                          |  63%  |                                                                              |=============================================                         |  64%  |                                                                              |==============================================                        |  66%  |                                                                              |===============================================                       |  68%  |                                                                              |=================================================                     |  69%  |                                                                              |==================================================                    |  71%  |                                                                              |===================================================                   |  72%  |                                                                              |====================================================                  |  74%  |                                                                              |=====================================================                 |  76%  |                                                                              |======================================================                |  77%  |                                                                              |=======================================================               |  78%  |                                                                              |========================================================              |  80%  |                                                                              |=========================================================             |  82%  |                                                                              |==========================================================            |  83%  |                                                                              |===========================================================           |  84%  |                                                                              |============================================================          |  86%  |                                                                              |=============================================================         |  88%  |                                                                              |===============================================================       |  89%  |                                                                              |===============================================================       |  90%  |                                                                              |================================================================      |  92%  |                                                                              |==================================================================    |  94%  |                                                                              |===================================================================   |  96%  |                                                                              |====================================================================  |  97%  |                                                                              |===================================================================== |  98%  |                                                                              |======================================================================| 100%
tm_shape(Boulder_ct)+
  tm_borders()+
  tm_shape(Boulder_Playground_Sites)+
  tm_dots(size = 0.02, col = "blue", alpha = 0.7)

QUESTION 3

Boulder_TRAILS <- st_read('C:/Users/adrian.gallegos/OneDrive - BASIS.ed/Desktop/FALL UTSA/PROJECT 2/OSMP_Trails/OSMP_Trails.shp')
## Reading layer `OSMP_Trails' from data source 
##   `C:\Users\adrian.gallegos\OneDrive - BASIS.ed\Desktop\FALL UTSA\PROJECT 2\OSMP_Trails\OSMP_Trails.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 591 features and 33 fields
## Geometry type: LINESTRING
## Dimension:     XY
## Bounding box:  xmin: 3026145 ymin: 1211610 xmax: 3103037 ymax: 1285335
## Projected CRS: NAD83(HARN) / Colorado North (ftUS)
Boulder_ct <-tracts(state = "CO", county = "Boulder",cb=T)
## Retrieving data for the year 2022
tm_shape(Boulder_ct)+
  tm_borders()+
  tm_shape(Boulder_TRAILS)+
  tm_lines(col="blue")

QUESTION 4

Boulder_Parks_and_Rec_Sites <- st_read('C:/Users/adrian.gallegos/OneDrive - BASIS.ed/Desktop/FALL UTSA/PROJECT 2/Properties_Managed_by_Parks_and_Recreation_Polygons/Properties_Managed_by_Parks_and_Recreation_Polygons.shp')
## Reading layer `Properties_Managed_by_Parks_and_Recreation_Polygons' from data source `C:\Users\adrian.gallegos\OneDrive - BASIS.ed\Desktop\FALL UTSA\PROJECT 2\Properties_Managed_by_Parks_and_Recreation_Polygons\Properties_Managed_by_Parks_and_Recreation_Polygons.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 104 features and 41 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 3056235 ymin: 1230015 xmax: 3092617 ymax: 1275386
## Projected CRS: NAD83(HARN) / Colorado North (ftUS)
Boulder_ct <-tracts(state = "CO", county = "Boulder",cb=T)
## Retrieving data for the year 2022
tm_shape(Boulder_ct)+
  tm_borders()+
  tm_shape(Boulder_Parks_and_Rec_Sites)+
  tm_polygons(col="PARKREACH",
              palette="RdYlGn")

QUESTION 5

Boulder_TRAILS<-st_make_valid(Boulder_TRAILS)

Boulder_Parks_and_Rec_Sites<-st_make_valid(Boulder_Parks_and_Rec_Sites)

Boulder_TRAILS<-st_transform(Boulder_TRAILS,crs = 4326)

Boulder_Parks_and_Rec_Sites<-st_transform(Boulder_Parks_and_Rec_Sites,crs = 4326)

Trails_and_Parks_ct <- st_intersection(Boulder_TRAILS, Boulder_Parks_and_Rec_Sites)
## Warning: attribute variables are assumed to be spatially constant throughout
## all geometries

QUESTION 6 - NO CODE NEEDED

QUESTION 7

library(raster)
## Loading required package: sp
DEM_Boulder <- raster('C:/Users/adrian.gallegos/OneDrive - BASIS.ed/Desktop/FALL UTSA//PROJECT 2/USGS_1_n41w106_20220331.tif')

DEM_Boulder <- setMinMax(DEM_Boulder)

cellStats(DEM_Boulder, max)
## [1] 4342.417
cellStats(DEM_Boulder, min)
## [1] 1470.28

QUESTION 8

plot(DEM_Boulder < 350, main  = "Elevation criteria",
             col = c("#ffffff", "#0000ff"))

QUESTION 9

plot(terrain(DEM_Boulder, opt = "slope", unit = "degrees") < 3,
     main = "Slope criteria",
     col = c("#ffffff", "#ff9900"))

QUESTION 10

plot(terrain(DEM_Boulder, opt = "aspect", unit = "degrees") > 22.5 &
       terrain (DEM_Boulder, opt = "aspect", unit = "degrees") < 157.5,
     main = "Aspect criteria")

SUMMARY OF FINDINGS:

The Hispanic population makes up a greater percentage of Boulder County’s overall population particularly in the western and northwestern sections of the county, where two census tracts have a Hispanic population making up over 40 percent of their entire population. It is also heavily represented (up to 30 percent)in sections of central Boulder. In all other parts of the county, the Hispanic population makes up less than 10 percent of the total population. As of the 2020 Census, 22.7% of Colorado’s population was Hispanic.

Boulder’s parks and playgrounds are relatively well spread out throughout the center of the city, with a slightly greater concentration towards the southern and eastern edge. Boulder’s network of trails is mostly found to the south and west of the city’s center. All of this corresponds with the topography of the region, as the slope increases dramatically in the western two-thirds of the region. The entire area surveyed for Boulder County is at an elevation above 350 meters.