knitr::opts_chunk$set( collapse = TRUE, comment = "#>", eval=F )
This notebook will demonstrate how several non-climate indicators are created. We will load the images, map them, and then combine them all into one multi-band image for extraction purposes. At the end I will wrap the process into one function which will be available in the surveyGEER
library
library(surveyGEER) library(rgee) library(sf) ee_Initialize()
city_access <- ee$Image("Oxford/MAP/accessibility_to_cities_2015_v1_0") healthcare_access <- ee$Image("Oxford/MAP/accessibility_to_healthcare_2019") srtm_landforms = ee$Image("CSP/ERGo/1_0/Global/SRTM_landforms") alos_landforms = ee$Image("CSP/ERGo/1_0/Global/ALOS_landforms") srtm_dem <- ee$Image("CGIAR/SRTM90_V4") # lets use the bounding box of somalia to center our map ee_bbox <- sf::st_bbox(som_boundary) |> sf::st_as_sfc() |> sf_as_ee()
Below we set the visualization parameters for each map and save each map to an object.
somalia_city_access_viz <- list(min=0, max= 1000, palette=list("#green","yellow","red") ) somalia_health_access_viz <- list(min=0, max= 1000, palette=list("gred","yellow","red"), bands=list("accessibility") ) somalia_health_access_walking_viz <- list(min=0, max= 1000, palette=list("green","yellow","red"), bands=list("accessibility_walking_only") ) srtm_viz <- get_metadata_palette_viz(srtm_landforms,bands = "constant") m1_city_access2015 <- Map$addLayer( city_access, visParams = somalia_city_access_viz ) m2_health_access2019 <- Map$addLayer( healthcare_access, visParams = somalia_health_access_viz ) m3_health_access_walking_2019 <- Map$addLayer( healthcare_access, visParams = somalia_health_access_walking_viz ) m4_srtm_landform<- Map$addLayer(srtm_landforms,visParams = srtm_viz,"srtm_landform")
We can then map all the layers at once
Map$centerObject(ee_bbox,6) m1_city_access2015+ m2_health_access2019+ m3_health_access_walking_2019+ m4_srtm_landform
If we want to extract this values to points or zones (polygons) later it will be easiest to just combine them into one multi-band image that we can just perform one ee_extract
or ee_extract_tidy
on.
city_access$ select("accessibility")$ rename("city_accessibility2015")$ addBands( healthcare_access$select(list("accessibility","accessibility_walking_only"))$ rename(list("healthcare_accessibility2019","healthcare_accessbility_walking_only2019")) )$ addBands(srtm_landforms$rename("srtm_landforms"))$ addBands(alos_landforms$rename("alos_landforms"))$ addBands(srtm_dem$rename("srtm4_dem"))$ bandNames()$getInfo()
Below we put the above into one generic function. This function has also been added to the surveyGEER
library for portability.
#' get_oxford_access_indicators #' #' @return multi-band image with #' @export #' #' @examples get_oxford_access_indicators <- function(return_tidyee=F){ city_access <- ee$Image("Oxford/MAP/accessibility_to_cities_2015_v1_0") healthcare_access <- ee$Image("Oxford/MAP/accessibility_to_healthcare_2019") city_access <- city_access$set("system:time_start",ee$Date("2015-01-01")) healthcare_access <- healthcare_access$set("system:time_start",ee$Date("2019-01-01")) res <- city_access$ select("accessibility")$ rename("city_accessibility2015")$ addBands( healthcare_access$select(list("accessibility","accessibility_walking_only"))$ rename(list("healthcare_accessibility2019","healthcare_accessbility_walking_only2019")) ) if(return_tidyee){ res <- as_tidyee(res) } return(res) } #' get_geomorph_landforms #' #' @return image or tidyee with image #' @export #' #' @examples get_geomorph_landform_indicators <- function(return_tidyee=F){ srtm_landforms = ee$Image("CSP/ERGo/1_0/Global/SRTM_landforms") alos_landforms = ee$Image("CSP/ERGo/1_0/Global/ALOS_landforms") # ee_get_date_img(srtm_landforms) res <- srtm_landforms$ rename("srtm_landforms")$ set("system:time_start",ee$Date("2022-01-01"))$ addBands(alos_landforms$rename("alos_landforms")) if(return_tidyee){ res <- as_tidyee(res) } return(res) } #' get_non_climate_indicators #' #' @return ee$Image with one band for each indicator #' @export #' #' @examples \dontrun{ #' library(surveyGEER) #' non_climate_indicators<-get_non_climate_indicators() #' } #' get_non_climate_indicators <- function(){ city_access <- ee$Image("Oxford/MAP/accessibility_to_cities_2015_v1_0") healthcare_access <- ee$Image("Oxford/MAP/accessibility_to_healthcare_2019") srtm_landforms = ee$Image("CSP/ERGo/1_0/Global/SRTM_landforms") alos_landforms = ee$Image("CSP/ERGo/1_0/Global/ALOS_landforms") city_access$ select("accessibility")$ rename("city_accessibility2015")$ addBands( healthcare_access$select(list("accessibility","accessibility_walking_only"))$ rename(list("healthcare_accessibility2019","healthcare_accessbility_walking_only2019")) )$ addBands(srtm_landforms$rename("srtm_landforms"))$ addBands(alos_landforms$rename("alos_landforms")) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.