##########################################################
# #
# Course: URP-5363-901-202410 #
# Assignment: 5 #
# #
# Student: Bradley Abbott #
# Student ID: Wuh344 #
# #
#####################################################################################################
# #
# 1. Download the "2017 BOND PROGRAM LINE " shapefile data from #
# https://www.sanantonio.gov/GIS/GISDataLinks to an external site. to an external site. and #
# visualize the lines (in green) with bexar county census tracts as the background. (2') #
# #
# 2. Download the "LIBRARIES " shapefile data from https://www.sanantonio.gov/GIS/GISDataLinks #
# to an external site. to an external site. and visualize the library point (in red) with bexar #
# county census tracts as the background. Make the map interactive using tmap_mode("view") (2'). #
# #
# 3. Read the raster file (LC09_028040_20230826.tif) Download LC09_028040_20230826.tif)Open this #
# document with ReadSpeaker docReader, which is the land surface temperature of Dallas. (1') #
# #
# 4. Convert the Kelvin into Celsius (C = K - 273.15) and then plot the raster data. (1') #
# #
# 5. Only visualize the areas with temperatures higher than 40 Degree Celsius (1'). #
# #
# 6. Publish you code and results to Rpubs using Rmarkdown (1'). # #
# # #
#####################################################################################################
install.packages('sf',repos = "http://cran.us.r-project.org")
## Installing package into 'C:/Users/bradw/AppData/Local/R/win-library/4.3'
## (as 'lib' is unspecified)
## package 'sf' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\bradw\AppData\Local\Temp\Rtmpu0nris\downloaded_packages
library(sf)
## Warning: package 'sf' was built under R version 4.3.2
## Linking to GEOS 3.11.2, GDAL 3.7.2, PROJ 9.3.0; sf_use_s2() is TRUE
install.packages('tigris',repos = "http://cran.us.r-project.org")
## Installing package into 'C:/Users/bradw/AppData/Local/R/win-library/4.3'
## (as 'lib' is unspecified)
## package 'tigris' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\bradw\AppData\Local\Temp\Rtmpu0nris\downloaded_packages
library(tigris)
## Warning: package 'tigris' was built under R version 4.3.2
## To enable caching of data, set `options(tigris_use_cache = TRUE)`
## in your R script or .Rprofile.
install.packages('tmap',repos = "http://cran.us.r-project.org")
## Installing package into 'C:/Users/bradw/AppData/Local/R/win-library/4.3'
## (as 'lib' is unspecified)
## package 'tmap' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\bradw\AppData\Local\Temp\Rtmpu0nris\downloaded_packages
library(tmap)
## Warning: package 'tmap' was built under R version 4.3.2
## Breaking News: tmap 3.x is retiring. Please test v4, e.g. with
## remotes::install_github('r-tmap/tmap')
install.packages('tidycensus',repos = "http://cran.us.r-project.org")
## Installing package into 'C:/Users/bradw/AppData/Local/R/win-library/4.3'
## (as 'lib' is unspecified)
## package 'tidycensus' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\bradw\AppData\Local\Temp\Rtmpu0nris\downloaded_packages
library(tidycensus)
## Warning: package 'tidycensus' was built under R version 4.3.2
install.packages('raster',repos = "http://cran.us.r-project.org")
## Installing package into 'C:/Users/bradw/AppData/Local/R/win-library/4.3'
## (as 'lib' is unspecified)
## package 'raster' successfully unpacked and MD5 sums checked
## Warning: cannot remove prior installation of package 'raster'
## Warning in file.copy(savedcopy, lib, recursive = TRUE): problem copying
## C:\Users\bradw\AppData\Local\R\win-library\4.3\00LOCK\raster\libs\x64\raster.dll
## to C:\Users\bradw\AppData\Local\R\win-library\4.3\raster\libs\x64\raster.dll:
## Permission denied
## Warning: restored 'raster'
##
## The downloaded binary packages are in
## C:\Users\bradw\AppData\Local\Temp\Rtmpu0nris\downloaded_packages
library(raster)
## Warning: package 'raster' was built under R version 4.3.2
## Loading required package: sp
# Step 1. Download the "2017 BOND PROGRAM LINE " shapefile data from #
# https://www.sanantonio.gov/GIS/GISDataLinks to an external site. to an external site. and #
# visualize the lines (in green) with bexar county census tracts as the background. (2')
#
bexar_tracts<- tracts(state = "TX", county = "Bexar",cb=T)
## Retrieving data for the year 2021
##
|
| | 0%
|
|= | 1%
|
|= | 2%
|
|== | 2%
|
|== | 3%
|
|== | 4%
|
|=== | 4%
|
|=== | 5%
|
|==== | 5%
|
|==== | 6%
|
|===== | 7%
|
|===== | 8%
|
|====== | 8%
|
|====== | 9%
|
|======= | 9%
|
|======= | 10%
|
|======== | 11%
|
|======== | 12%
|
|========= | 12%
|
|========= | 13%
|
|========== | 14%
|
|========== | 15%
|
|=========== | 15%
|
|=========== | 16%
|
|============ | 17%
|
|============ | 18%
|
|============= | 18%
|
|============= | 19%
|
|============== | 20%
|
|=============== | 21%
|
|=============== | 22%
|
|================ | 22%
|
|================ | 23%
|
|================= | 24%
|
|================= | 25%
|
|================== | 25%
|
|================== | 26%
|
|=================== | 27%
|
|=================== | 28%
|
|==================== | 28%
|
|==================== | 29%
|
|===================== | 29%
|
|===================== | 30%
|
|===================== | 31%
|
|====================== | 31%
|
|====================== | 32%
|
|======================= | 32%
|
|======================= | 33%
|
|======================== | 34%
|
|======================== | 35%
|
|========================= | 35%
|
|========================= | 36%
|
|========================== | 37%
|
|========================== | 38%
|
|=========================== | 38%
|
|=========================== | 39%
|
|============================ | 40%
|
|============================ | 41%
|
|============================= | 41%
|
|============================= | 42%
|
|============================== | 43%
|
|============================== | 44%
|
|=============================== | 44%
|
|=============================== | 45%
|
|================================ | 45%
|
|================================ | 46%
|
|================================= | 46%
|
|================================= | 47%
|
|================================= | 48%
|
|================================== | 48%
|
|================================== | 49%
|
|=================================== | 49%
|
|=================================== | 50%
|
|==================================== | 51%
|
|==================================== | 52%
|
|===================================== | 52%
|
|===================================== | 53%
|
|====================================== | 54%
|
|====================================== | 55%
|
|======================================= | 55%
|
|======================================= | 56%
|
|======================================== | 57%
|
|======================================== | 58%
|
|========================================= | 58%
|
|========================================= | 59%
|
|========================================== | 59%
|
|========================================== | 60%
|
|=========================================== | 61%
|
|=========================================== | 62%
|
|============================================ | 62%
|
|============================================ | 63%
|
|============================================= | 64%
|
|============================================= | 65%
|
|============================================== | 65%
|
|============================================== | 66%
|
|=============================================== | 67%
|
|=============================================== | 68%
|
|================================================ | 68%
|
|================================================ | 69%
|
|================================================= | 70%
|
|================================================= | 71%
|
|================================================== | 71%
|
|================================================== | 72%
|
|=================================================== | 72%
|
|=================================================== | 73%
|
|==================================================== | 74%
|
|==================================================== | 75%
|
|===================================================== | 75%
|
|===================================================== | 76%
|
|====================================================== | 77%
|
|====================================================== | 78%
|
|======================================================= | 78%
|
|======================================================= | 79%
|
|======================================================== | 80%
|
|======================================================== | 81%
|
|========================================================= | 81%
|
|========================================================= | 82%
|
|========================================================== | 82%
|
|========================================================== | 83%
|
|========================================================== | 84%
|
|=========================================================== | 84%
|
|=========================================================== | 85%
|
|============================================================ | 85%
|
|============================================================ | 86%
|
|============================================================= | 86%
|
|============================================================= | 87%
|
|============================================================= | 88%
|
|============================================================== | 88%
|
|============================================================== | 89%
|
|=============================================================== | 89%
|
|=============================================================== | 90%
|
|================================================================ | 91%
|
|================================================================ | 92%
|
|================================================================= | 92%
|
|================================================================= | 93%
|
|================================================================== | 94%
|
|================================================================== | 95%
|
|=================================================================== | 95%
|
|=================================================================== | 96%
|
|==================================================================== | 97%
|
|===================================================================== | 98%
|
|===================================================================== | 99%
|
|======================================================================| 99%
|
|======================================================================| 100%
bexar_county_bond_2017_sf <- st_read(dsn="G:\\My Drive\\School\\URP 5363 R Intro\\Assignment 5\\BondProjectLines2017 (1)\\BondProjectLines2017\\BondProjectLines2017.shp")
## Reading layer `BondProjectLines2017' from data source
## `G:\My Drive\School\URP 5363 R Intro\Assignment 5\BondProjectLines2017 (1)\BondProjectLines2017\BondProjectLines2017.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 69 features and 24 fields
## Geometry type: MULTILINESTRING
## Dimension: XY
## Bounding box: xmin: 2078269 ymin: 13665110 xmax: 2168346 ymax: 13783530
## Projected CRS: NAD83 / Texas South Central (ftUS)
bexar_county_bond_2017_sf<-st_transform(bexar_county_bond_2017_sf,crs=4326)
buffer_distance <- 0.01 # adjust as needed
bexar_county_bond_2017_sf <- st_buffer(bexar_county_bond_2017_sf, dist = buffer_distance)
tm_shape(bexar_tracts) +
tm_borders() +
tm_shape(bexar_county_bond_2017_sf) +
tm_borders(lwd = 2, col = "red") + # Customize line appearance
tm_layout(frame = FALSE)
libraries_bc <- st_read(dsn="G:\\My Drive\\School\\URP 5363 R Intro\\Assignment 5\\Libraries\\Libraries\\Libraries.shp")
## Reading layer `Libraries' from data source
## `G:\My Drive\School\URP 5363 R Intro\Assignment 5\Libraries\Libraries\Libraries.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 30 features and 9 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: 2075828 ymin: 13669240 xmax: 2170361 ymax: 13779280
## Projected CRS: NAD83 / Texas South Central (ftUS)
libraries_bc<-transform(libraries_bc,crs=4326)
# step 2. Download the "LIBRARIES " shapefile data from https://www.sanantonio.gov/GIS/GISDataLinks #
# to an external site. to an external site. and visualize the library point (in red) with bexar #
# county census tracts as the background. Make the map interactive using tmap_mode("view") (2'). #
tmap_mode("view")
## tmap mode set to interactive viewing
tm_shape(bexar_tracts) +
tm_borders() + # Add borders for polygons (customize as needed)
tm_shape(libraries_bc) +
tm_dots(size = 0.02, col = "red", alpha = 0.7) + # Customize point appearance
tm_basemap() +
tm_layout(title = "Bexar County Libraries", frame = FALSE)
# 3. Read the raster file (LC09_028040_20230826.tif) Download LC09_028040_20230826.tif)Open this #
# document with ReadSpeaker docReader, which is the land surface temperature of Dallas. (1') #
wd <- ("G:\\My Drive\\School\\URP 5363 R Intro\\Assignment 5\\")
setwd(wd)
LST <- raster(paste0(wd, "LC09_028040_20230826.tif"))
# calculate and save the min and max values of the raster to the raster object
LST <- setMinMax(LST)
# 4. Convert the Kelvin into Celsius (C = K - 273.15) and then plot the raster data. (1') #
LST<-LST-273.15
#
plot(LST,
main="LST of San Antonio") # add title with main
# create a plot of our raster
image(LST)
# 5. Only visualize the areas with temperatures higher than 40 Degree Celsius (1'). #
# specify the range of values that you want to plot in the LST
# just plot pixels between 250 and 300 m in elevation
image(LST, zlim=c(40,100))