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_chaneel <- st_read ("C:/Users/عمر/Desktop/Fall 2024/Rstudio/Week 13/StormChannels/StormChannels/StormChannels.shp")
## Reading layer `StormChannels' from data source
## `C:\Users\عمر\Desktop\Fall 2024\Rstudio\Week 13\StormChannels\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/عمر/Desktop/Fall 2024/Rstudio/Week 13/CorridorPlans/CorridorPlans/CorridorPlans.shp")
## Reading layer `CorridorPlans' from data source
## `C:\Users\عمر\Desktop\Fall 2024\Rstudio\Week 13\CorridorPlans\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_chaneel<-st_transform(storm_chaneel,crs = 4326)
Corridor_plan<-st_transform(Corridor_plan,crs = 4326)
#Q2
intersected_chaneel <- st_intersection(storm_chaneel, Corridor_plan)
## Warning: attribute variables are assumed to be spatially constant throughout
## all geometries
#Q3
bexar_ct <-tracts(state = "TX", county = "Bexar",cb=T)
## Retrieving data for the year 2022
## | | | 0% | |= | 1% | |= | 2% | |== | 3% | |=== | 4% | |=== | 5% | |==== | 5% | |==== | 6% | |======== | 12% | |========= | 13% | |========== | 14% | |=========== | 15% | |=========== | 16% | |============ | 17% | |============= | 19% | |============== | 20% | |=============== | 21% | |=============== | 22% | |================ | 22% | |================ | 23% | |=================== | 27% | |==================== | 29% | |===================== | 30% | |======================== | 34% | |========================= | 36% | |=========================== | 38% | |=========================== | 39% | |============================ | 40% | |============================== | 42% | |=============================== | 44% | |================================ | 46% | |================================= | 48% | |=================================== | 50% | |===================================== | 52% | |===================================== | 54% | |======================================= | 56% | |======================================== | 57% | |========================================= | 59% | |=========================================== | 61% | |============================================ | 63% | |============================================= | 64% | |============================================== | 65% | |=============================================================== | 90% | |=============================================================== | 91% | |================================================================== | 95% | |=================================================================== | 95% | |==================================================================== | 97% | |===================================================================== | 98% | |===================================================================== | 99% | |======================================================================| 100%
tm_shape(bexar_ct)+
tm_borders()+
tm_shape(intersected_chaneel)+
tm_lines(col = "blue")
#Q4
library(raster)
## Loading required package: sp
LST <- raster('C:/Users/عمر/Desktop/Fall 2024/Rstudio/Week 13/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() +
theme_minimal()
#Q6
plot(LST > 40, main = "LST above 40",
col = c("#ffffff", "#0000ff"))