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(tidycensus)
library(tigris)
## To enable caching of data, set `options(tigris_use_cache = TRUE)`
## in your R script or .Rprofile.
#1 Spatial Distribution of Percentage of Hispanic Population
var_hisp <- c(
totalpopulation = "B01003_001E",
hispanicpopulation = "B03002_012E")
travis_data <- get_acs(
geography = "tract",
variable = var_hisp,
state = "TX",
county = "Travis",
geometry = TRUE,
output = "wide",
year = 2022
)
## Getting data from the 2018-2022 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% | |= | 1% | |= | 2% | |== | 2% | |== | 3% | |=== | 4% | |=== | 5% | |==== | 5% | |==== | 6% | |===== | 7% | |====== | 8% | |====== | 9% | |======= | 9% | |======= | 10% | |======== | 11% | |======== | 12% | |========= | 12% | |========= | 13% | |========== | 14% | |========== | 15% | |=========== | 16% | |============= | 18% | |============== | 19% | |=============== | 21% | |================ | 22% | |================ | 23% | |================= | 24% | |================= | 25% | |================== | 26% | |=================== | 27% | |==================== | 28% | |==================== | 29% | |===================== | 30% | |====================== | 31% | |====================== | 32% | |======================= | 33% | |======================== | 34% | |========================= | 35% | |========================= | 36% | |========================== | 37% | |=========================== | 38% | |=========================== | 39% | |============================ | 41% | |============================= | 41% | |============================== | 42% | |============================== | 43% | |================================ | 45% | |================================ | 46% | |================================= | 47% | |================================== | 49% | |=================================== | 50% | |==================================== | 51% | |==================================== | 52% | |===================================== | 53% | |====================================== | 54% | |====================================== | 55% | |======================================== | 56% | |======================================== | 57% | |========================================= | 58% | |========================================== | 59% | |========================================== | 60% | |============================================ | 62% | |============================================ | 63% | |============================================= | 64% | |============================================== | 65% | |============================================== | 66% | |=============================================== | 67% | |================================================ | 68% | |================================================ | 69% | |================================================= | 70% | |================================================== | 71% | |================================================== | 72% | |=================================================== | 73% | |==================================================== | 75% | |===================================================== | 76% | |======================================================= | 78% | |======================================================== | 79% | |======================================================== | 80% | |========================================================= | 82% | |========================================================== | 83% | |=========================================================== | 85% | |============================================================ | 86% | |============================================================= | 87% | |============================================================== | 88% | |=============================================================== | 90% | |================================================================ | 92% | |================================================================= | 92% | |=================================================================== | 95% | |==================================================================== | 97% | |===================================================================== | 99% | |======================================================================| 100%
travis_data$hispanic_pct <-travis_data$hispanicpopulation/travis_data$totalpopulation
tm_shape (travis_data) +
tm_polygons("hispanic_pct") +
tm_compass(position = c("left", "bottom")) +
tm_scale_bar(position = c("left", "bottom")) +
tm_layout(
frame = FALSE,
title = "Distribution of Hispanic Population Percentage",
legend.position = c("center", "bottom"),
legend.outside = TRUE)
#2 Point - Park Trail Heads
ParkTrailHeads<-st_read(dsn = "D:/Documents/RFiles/Datasets/ParkTrailheads/ParkTrailheads.shp")
## Reading layer `ParkTrailheads' from data source
## `D:\Documents\RFiles\Datasets\ParkTrailheads\ParkTrailheads.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 82 features and 1 field
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: 2061690 ymin: 13636410 xmax: 2169838 ymax: 13773880
## Projected CRS: NAD83 / Texas South Central (ftUS)
bexar_tracts <- tracts(state="tx", county = "Bexar",cb=T)
## Retrieving data for the year 2022
tm_shape(bexar_tracts)+
tm_borders()+
tm_shape(ParkTrailHeads)+
tm_dots(col='green')+
tm_layout(frame = FALSE)
#3 Line - Park Trails
ParkTrails <- st_read(dsn = "D:/Documents/RFiles/Datasets/ParkTrails/ParkTrails.shp")
## Reading layer `ParkTrails' from data source
## `D:\Documents\RFiles\Datasets\ParkTrails\ParkTrails.shp' using driver `ESRI Shapefile'
## Simple feature collection with 4969 features and 7 fields
## Geometry type: MULTILINESTRING
## Dimension: XY
## Bounding box: xmin: 2040501 ymin: 13636400 xmax: 2212873 ymax: 13806060
## Projected CRS: NAD83 / Texas South Central (ftUS)
tm_shape(bexar_tracts) +
tm_borders()+
tm_shape(ParkTrails) +
tm_lines(lwd = 2, col='darkgreen') +
tm_layout(frame = FALSE)
#4 Polygons - Park Boundaries
ParkBoundaries <- st_read(dsn = "D:/Documents/RFiles/Datasets/ParkBoundaries/ParkBoundaries.shp")
## Reading layer `ParkBoundaries' from data source
## `D:\Documents\RFiles\Datasets\ParkBoundaries\ParkBoundaries.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 337 features and 8 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: 2027892 ymin: 13636380 xmax: 2213081 ymax: 13807110
## Projected CRS: NAD83 / Texas South Central (ftUS)
tmap_options(check.and.fix = TRUE)
tm_shape(bexar_tracts) +
tm_borders()+
tm_shape(ParkBoundaries) +
tm_polygons(col='lightgreen') +
tm_layout(frame = FALSE)
## Warning: The shape ParkBoundaries is invalid (after reprojection). See
## sf::st_is_valid
DetentionAreas <- st_read(dsn = "D:/Documents/RFiles/Datasets/MandatoryDetentionArea/MandatoryDetentionArea.shp")
## Reading layer `MandatoryDetentionArea' from data source
## `D:\Documents\RFiles\Datasets\MandatoryDetentionArea\MandatoryDetentionArea.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 19 features and 5 fields
## Geometry type: POLYGON
## Dimension: XY
## Bounding box: xmin: 2023208 ymin: 13646310 xmax: 2175013 ymax: 13812030
## Projected CRS: NAD83 / Texas South Central (ftUS)
tm_shape(bexar_tracts) +
tm_borders()+
tm_shape(DetentionAreas) +
tm_polygons(col='blue') +
tm_layout(frame = FALSE)
## Warning: The shape DetentionAreas is invalid (after reprojection). See
## sf::st_is_valid
#5 Overlay Analysis
ParkBoundaries <- st_make_valid(ParkBoundaries)
DetentionAreas <- st_make_valid(DetentionAreas)
ParkBoundaries <- st_transform(ParkBoundaries,crs = 4326)
DetentionAreas <- st_transform(DetentionAreas,crs = 4326)
CatchmentParks <- st_intersection(ParkBoundaries, DetentionAreas)
## Warning: attribute variables are assumed to be spatially constant throughout
## all geometries
tm_shape(bexar_tracts) +
tm_borders() + # Add borders for polygons (customize as needed)
tm_shape(CatchmentParks) +
tm_polygons(col='red')
#tm_dots(size = 0.02, col = "red", alpha = 0.7)
#6 DEM Data of Travis County
library(sp)
library(raster)
DEM_TRAV <- raster("D:/Documents/RFiles/Maps/USGS_1_n31w098_20211103.tif")
#7 Min and Max Elevations of Travis County
DEM_TRAV <- setMinMax(DEM_TRAV)
cellStats(DEM_TRAV,min)
## [1] 79.33
cellStats(DEM_TRAV,max)
## [1] 397.6903
#8 Elevation Criteria
plot(DEM_TRAV < 350, main = "Elevation Criteria",
col = c("White", "Black"))
#9 Slope Criteria
plot(terrain(DEM_TRAV,opt = "slope", unit = "degrees") < 3,
main = "Slope Criteria",
col = c("White", "Black"))
#10 Aspect Criteria
plot(terrain(DEM_TRAV, opt = "aspect", unit = "degrees") > 22.5 &
terrain(DEM_TRAV, opt = "aspect", unit = "degrees") < 157.5,
main = "Aspect Criteria")
#11 Findings
#Park trails, trail heads, and boundaries were mapped in Bexar County. Additionally, water detention areas were mapped in blue. An overlay analysis overlaps both the park boundaries and detention areas to represent which parks acts as catchment zones (in the project it is called catchment parks).
#Elevation Criteria has the white represent land under 350m that means majority of Travis County is higher in elevation. The figure on question #8 indicates that all the black color represents area above 350 meters. The figure on question #9 is the slope figure that represents how steep the slopes are in the county. As seen in the figure, the black color represents slopes that are more than 3 degrees. The last figure in question #10 represents the Aspect CritQeria of Travis County. The data showcases the land that faces East or 22.5 degrees up to 157.5 degrees.