Closed ifeanyi588 closed 3 years ago
Maybe ?ee_extract
can help:
library(rgee)
ee_Initialize()
# World FeatureCollection dataset
countries <- ee$FeatureCollection("USDOS/LSIB_SIMPLE/2017")
# Select Cameroon
cameroon <- countries %>%
ee$FeatureCollection$filter(
ee$Filter$eq('country_na', 'Cameroon')
) %>%
ee$FeatureCollection$first() %>%
ee$Feature() %>%
ee$Feature$geometry()
# Display Cameroon map
Map$centerObject(camerun)
Map$addLayer(camerun)
# Get time series
collection <- ee$ImageCollection('NOAA/DMSP-OLS/NIGHTTIME_LIGHTS') %>%
ee$ImageCollection$select('stable_lights')
lights_ts <- ee_extract(collection, cameroon)
plot(as.numeric(lights_ts), type ="l")
Thanks so much! This is extremely helpful.
My apologies because I sense this is a trivial question but I am an R programmer but new to GIS analysis. I have a polygon shapefile for Cameroun. I am simply looking to be able to add a variable for night time lights. I know what the indicator in question and from what ImageCollection I'd be getting the data. However, I cant tell which of your tutorials I should be looking at to figure out how to do this. Any quick thoughts would be useful.