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.
#Q1
storm_channel <-st_read("C:/Users/dejmo/OneDrive/Documents/URP Cert/URP 5363- Planning Methods I/Assignment 5/StormChannels/StormChannels.shp")
## Reading layer `StormChannels' from data source 
##   `C:\Users\dejmo\OneDrive\Documents\URP Cert\URP 5363- Planning Methods I\Assignment 5\StormChannels\StormChannels.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 12042 features and 17 fields
## Geometry type: MULTILINESTRING
## Dimension:     XY
## Bounding box:  xmin: 2024999 ymin: 13600410 xmax: 2249487 ymax: 13824430
## Projected CRS: NAD83 / Texas South Central (ftUS)
corridor_plan <-st_read("C:/Users/dejmo/OneDrive/Documents/URP Cert/URP 5363- Planning Methods I/Assignment 5/CorridorPlans/CorridorPlans.shp")
## Reading layer `CorridorPlans' from data source 
##   `C:\Users\dejmo\OneDrive\Documents\URP Cert\URP 5363- Planning Methods I\Assignment 5\CorridorPlans\CorridorPlans.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 12 features and 4 fields
## Geometry type: POLYGON
## Dimension:     XY
## Bounding box:  xmin: 2058688 ymin: 13665110 xmax: 2178301 ymax: 13793820
## Projected CRS: NAD83 / Texas South Central (ftUS)
storm_channel<-transform(storm_channel,crs = 4326)

corridor_plan<-transform(corridor_plan,crs = 4326)

#Q2
intersected_channel <- st_intersection(storm_channel, corridor_plan)
## Warning: attribute variables are assumed to be spatially constant throughout
## all geometries
bexar_ct <-tracts(state = "TX", county = "Bexar", cb=T)
## Retrieving data for the year 2022
##   |                                                                              |                                                                      |   0%  |                                                                              |=                                                                     |   1%  |                                                                              |=                                                                     |   2%  |                                                                              |==                                                                    |   2%  |                                                                              |==                                                                    |   3%  |                                                                              |===                                                                   |   4%  |                                                                              |===                                                                   |   5%  |                                                                              |====                                                                  |   5%  |                                                                              |====                                                                  |   6%  |                                                                              |=====                                                                 |   7%  |                                                                              |=====                                                                 |   8%  |                                                                              |======                                                                |   8%  |                                                                              |======                                                                |   9%  |                                                                              |=======                                                               |  10%  |                                                                              |=======                                                               |  11%  |                                                                              |========                                                              |  11%  |                                                                              |=========                                                             |  12%  |                                                                              |=========                                                             |  13%  |                                                                              |==========                                                            |  15%  |                                                                              |===========                                                           |  15%  |                                                                              |============                                                          |  17%  |                                                                              |=============                                                         |  18%  |                                                                              |==============                                                        |  20%  |                                                                              |================                                                      |  22%  |                                                                              |================                                                      |  23%  |                                                                              |=================                                                     |  24%  |                                                                              |==================                                                    |  26%  |                                                                              |===================                                                   |  28%  |                                                                              |=====================                                                 |  30%  |                                                                              |======================                                                |  32%  |                                                                              |==========================                                            |  38%  |                                                                              |============================                                          |  40%  |                                                                              |=============================                                         |  42%  |                                                                              |===============================                                       |  44%  |                                                                              |================================                                      |  46%  |                                                                              |====================================                                  |  52%  |                                                                              |========================================                              |  57%  |                                                                              |===========================================                           |  61%  |                                                                              |==============================================                        |  66%  |                                                                              |=================================================                     |  71%  |                                                                              |=====================================================                 |  76%  |                                                                              |=========================================================             |  81%  |                                                                              |============================================================          |  86%  |                                                                              |===============================================================       |  91%  |                                                                              |==================================================================    |  94%  |                                                                              |===================================================================   |  96%  |                                                                              |===================================================================== |  99%  |                                                                              |======================================================================| 100%
tm_shape(bexar_ct)+
  tm_borders()+
  tm_shape(intersected_channel)+
  tm_lines(col="red")

#Q4
library(raster)
## Loading required package: sp
LST <- raster("C:/Users/dejmo/OneDrive/Documents/URP Cert/URP 5363- Planning Methods I/Assignment 5/LC09_028040_20230826.tif")

#Q5
LST <- setMinMax(LST)
LST <- LST - 273.15
cellStats(LST, max)
## [1] 61.28771
library(ggplot2)
library(rasterVis)
## Warning: package 'rasterVis' was built under R version 4.4.2
## Loading required package: lattice
gplot(LST)+
  geom_tile(aes(fill = value))+
  scale_fill_viridis_c() +
  labs(title = "Digital Elevation Model", fill = "Elevation")+
  theme_minimal()

#Q6
plot(LST > 40, main = "LST>40",
     col = c("#ffffff", "#0000ff"))

R Markdown

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:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.