gee initialize
library(rgee)
ee_Initialize()
load shapefile as sf object and convert it into EE object
library(sf)
manchester_boundary_ee <- st_read(here::here("prac7_data",
"Manchester_boundary",
"Manchester_boundary.shp")) %>%
sf_as_ee()
manchester_boundary<-manchester_boundary_ee$first()$geometry()
Load Landsat 8 image collection and filter by date, region boundry. Get the lowest cloud cover image.
image <- ee$ImageCollection('LANDSAT/LC08/C01/T1_TOA')$
filterDate('2020-01-01', '2020-11-21')$
filterBounds(manchester_boundary)$
sort("CLOUD_COVER",T)$
first()$
clip(manchester_boundary)
False color composite
Map$centerObject(manchester_boundary)
FalseColorVisParams <- list(bands = c("B5", "B4", "B3"),min = 0,max = 0.5,gamma = c(0.95,1.1,1))
Map$addLayer(eeObject = image,FalseColorVisParams,name = "False color composite")
True color composite.
Map$centerObject(manchester_boundary)
TrueColorVisParams <- list(bands = c("B4", "B3", "B2"),min = 0, max = 0.5, gamma = c(0.95,1.1,1))
Map$addLayer(eeObject = image,TrueColorVisParams,name = "True color composite")
To convert the EE image object into image object
library(googledrive)
raster <- ee_as_raster(
image = image,
region = manchester_boundary,
via = "drive"
)