Skip to content

MVanDenburg92/RGEE_Shiny

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn LinkedIn2


Logo

Phenology Analyses with GEE and R

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
  1. About The Project
  2. Getting Started
  3. Running the Apps
  4. Future Work
  5. Contact
  6. Sources

About the Project

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.

Objective

  • 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 and GreenBrown.
  • The metrics we are extracting follows
    1. Start of season (SOS)
    2. End of season (EOS),
    3. Point of peak value (POP)
    4. Length of season(LOS)

Built With

Getting Started

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.

Prerequisites

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:

Required 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")

RGEE

RGEE

What is Google Earth Engine?

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!

Installation

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

Setup

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

GreenBrown

Greenbrown

#Install greenbrown
install.packages("greenbrown", repos="http://R-Forge.R-project.org")
library(greenbrown)

Getting the Apps to Run

Shiny Dashboard

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")

Shiny App

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"!

Product Updates

Fall 2020 Product

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.

Dashboard Application

Dashboard

Shiny App Application

Shiny App

Future Work

Spring 2020 End Product:

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

Contact Us

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

Sources

RGEE

https://csaybar.github.io/rgee-examples/#What%20is%20rgee%3f https://github.com/MVanDenburg92/RGEE_Workshop

Greenbrown

http://greenbrown.r-forge.r-project.org/index.php

Project Links

http://earthobservations.org/article.php?id=447 https://eodatascience.com/About/Company-Overview

Phenology

https://www.youtube.com/watch?v=RNs3XpRmRfI

!-- MARKDOWN LINKS & IMAGES -->

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published