Two case examples of Phenological imagery analysis with R and Google Earth Engine
Explore the docs»
View Demo
.
Report Bug
·
Request Feature
Table of Contents
Last year Group on Earth Observations (GEO) and Google Earth Engine announced a call to action for Earth observations projects monitoring the pulse of the planet to apply for the GEO-GEE Programme. More than 50 projects were submitted from around the globe on a range of social and environmental topics including climate monitoring, water and coastal observations, sustainable development and other key areas related to environmental protection and conservation.
As one of the teams with a winning proposal, we begin a two-year journey to produce tangible societal benefits using the power of Earth observations coupled to Google Earth Engine. In partnership with EO Data Science, we are receiving in-kind technical support, mentoring and ongoing capacity development to ensure projects achieve their intended impact.
- Phenology is described as the study of timing of different event such as flowering, leafing, and migrations
- The goal of our project is to develop essential biodiversity variables using Google Earth Engine to extract and analyze phenological metrics to explore trends over time using two key packages
RGEE
andGreenBrown
. - The metrics we are extracting follows
- Start of season (SOS)
- End of season (EOS),
- Point of peak value (POP)
- Length of season(LOS)
This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.
You need to have an R version of 4.0 or greater and an updated R studio. In addition you will need the following packages:
#
"shiny","ggplot2","sf","sp", "tidyverse", "raster", "qdapRegex", "lubridate", "doParallel", "foreach","parallel", "gsubfn","rgdal", "magrittr", "kimisc"
You cane quickly check for them and install them by using the below function:
using<-function(...) {
libs<-unlist(list(...))
req<-unlist(lapply(libs,require,character.only=TRUE))
need<-libs[req==FALSE]
n<-length(need)
if(n>0){
libsmsg<-if(n>2) paste(paste(need[1:(n-1)],collapse=", "),",",sep="") else need[1]
print(libsmsg)
if(n>1){
libsmsg<-paste(libsmsg," and ", need[n],sep="")
}
libsmsg<-paste("The following packages could not be found: ",libsmsg,"\n\r\n\rInstall missing packages?",collapse="")
if(winDialog(type = c("yesno"), libsmsg)=="YES"){
install.packages(need)
lapply(need,require,character.only=TRUE)
}
}
}
using("shiny","ggplot2","sf","sp", "tidyverse", "raster", "qdapRegex", "lubridate", "doParallel", "foreach","parallel", "gsubfn","rgdal", "magrittr", "kimisc")
Google Earth Engine is a cloud-based platform that allows users to have an easy access to a petabyte-scale archive of remote sensing data and run geospatial analysis on Google’s infrastructure. Currently, Google offers support only for Python and JavaScript. rgee
will fill the gap starting to provide support to R!. Below you will find the comparison between the syntax of rgee
and the two Google-supported client libraries.
JS (Code Editor) | Python | R |
---|---|---|
var db = 'CGIAR/SRTM90_V4'
var image = ee.Image(db)
print(image.bandNames())
#> 'elevation' |
import ee
ee.Initialize()
db = 'CGIAR/SRTM90_V4'
image = ee.Image(db)
image.bandNames().getInfo()
#> [u'elevation'] |
library(rgee)
ee_Initialize()
db <- 'CGIAR/SRTM90_V4'
image <- ee$Image(db)
image$bandNames()$getInfo()
#> [1] "elevation" |
Quite similar, isn’t it?. However, there are additional smaller changes should consider when using Google Earth Engine with R. Please check the consideration section before you start coding!
Install the rgee
package from GitHub is quite simple, you just have to run in your R console as follows:
remotes::install_github("r-spatial/rgee")
rgee
depends on sf. Therefore, is necessary to install its external libraries, follow the installation steps specified here. If you are using a Debian-based operating system, you probably need to install virtualenv as well.
sudo pip3 install virtualenv
Prior to using rgee
you will need to install a Python version higher than 3.5 in their system. rgee
counts with an installation function (ee_install) which helps to setup rgee
correctly:
library(rgee)
## It is necessary just once
ee_install()
# Initialize Earth Engine!
ee_Initialize()
Additionally, you might use the functions below for checking the status of rgee dependencies and delete credentials.
ee_check() # Check non-R dependencies
ee_clean_credentials() # Remove credentials of a specific user
ee_clean_pyenv() # Remove reticulate system variables
#Install greenbrown
install.packages("greenbrown", repos="http://R-Forge.R-project.org")
library(greenbrown)
After copying and opening the script in R Studio, please be sure to replace the csv file name and path within line 18 with the file path to your own EVI dataset stored as a csv. See Below:
worc_EVI <- read.csv("../inst/extdata/worc_evi.csv")
After you get the prerequisite packages installed followed up by rgee and greenbrown, the next step is to get the app scripts! Click on the app of interest and Copy the code into an app.R script files within R studio.
After you set up your Shiny Web App script, please run the following lines BEFORE running the App to correctly load up both rgee and the reticulate package (allows for python libraries and functions to be used within R).
library(rgee)
ee_Initialize()
#DO NOT RUN library( UNTIL YOU HAVE INTIALIZED GEE| If you do, your system will brick because you need to define the python environment using rgee first.
library(reticulate)
Once you have these packages loaded up post-installation and initiallization, you are ready to run the app! Leave the code exactly how it is and click "Run App"!
Following our work from this semester, we are able to extract these metrics for over 7 years from 2000-2007 using only EVI and one site and visualize it on a shiny app which is hosted online on github for people to download and utilize.
Google Earth Engine App that allows the user to select an input region and extract these metrics based on user input: Imagery Collection Dates Desired Metric
I'm a GIS analyst with a mind for creative innovation and implementation. My interests lie is Urban applications of GIS, with interests in programmatic GIS and leveraging open source GIS technologies for smarter urban planning. As I head into the final year of my Masters in GIS at Clark University i’m working for Clark Labs as a Remote Sensing Research Assistant as part of the Half-Earth project with ESRI with the goal of modeling land change for each country in the world for the year 2050. Contact Miles
I am currently a second-year Master's student in the Geographic Information Science program at Clark University with a concentration in remote sensing. My interests include applying GIS and Remote Sensing to understand impacts of climate change and how it’s affecting our lives everyday. I am particularly interested in discovering how anthropogenic activity has modified our landscape and the implication it has on our community through using GIS as a tool. Contact Shreena
https://csaybar.github.io/rgee-examples/#What%20is%20rgee%3f https://github.com/MVanDenburg92/RGEE_Workshop
http://greenbrown.r-forge.r-project.org/index.php
http://earthobservations.org/article.php?id=447 https://eodatascience.com/About/Company-Overview
https://www.youtube.com/watch?v=RNs3XpRmRfI
!-- MARKDOWN LINKS & IMAGES -->