Giter Club home page Giter Club logo

explorergee's Introduction

exploreRGEE

The goal of exploreRGEE is to explore Google Earth Engine (GEE) in the Rstudio IDE. This package uses bindings and functions from rgee and other spatial packages (sf, leaflet) to explore Google Earth Engine collections relatively quickly while using R. This package is meant to be exploratory and experimental but also provides the user quick functions to reproducible tasks, e.g. repetitive workflows. The reason for doing this in R is that some people are not familiar with JavaScript or Python but versed in R and this provides easy access to use GEE with commonly used methods for exploratory data analysis (tidyverse).

Installation

Development version from GitHub with:

# install.packages("devtools")
devtools::install_github("joshualerickson/exploreRGEE")

# recommended
# https://github.com/mikejohnson51/AOI/tree/master/R
remotes::install_github("mikejohnson51/AOI")

Important Note

The backbone of this package relies on rgee and a GEE account (it’s free), so for more information go to the rgee website or the GEE website for more details on how to get set-up and also tons of functionality using the rgee package!

Similar Packages

Here is a list of similar packages that I’ve come across. Please let me know of any more!

rgee

eemont

earthEngineGrabR

geemap

Flow

The main flow of exploreRGEE is to get GEE data and then either vizualize (viz()), reduce regions (rr()) or look at time series (band()). For example,

get_*() %>% viz()
get_*() %>% rr()
get_*() %>% band()

Development

Contributions are welcome!

Example

This is a basic example which shows you how to solve a common problem: visualizing net annual NPP data and creating a time series.

library(exploreRGEE)
library(rgee)
library(AOI)

#this initializes the API
ee_Initialize()
#> -- rgee 1.0.8.9999 ---------------------------------- earthengine-api 0.1.249 -- 
#>  v email: not_defined
#>  v Initializing Google Earth Engine: v Initializing Google Earth Engine:  DONE!
#>  v Earth Engine user: users/joshualerickson 
#> --------------------------------------------------------------------------------

Let’s look at Northwestern Montana and the median NPP over a 30 year span (1986 to 2016). To do this, we’ll call the get_npp(). This gets the collection while doing some pre-processing steps, e.g. date range, cloud masking, etc. You could also just use the get_any() function and provide the appropriate arguments.

lincoln_county <- AOI::aoi_get(state = "Montana", county = "Lincoln")

npp <- get_npp(lincoln_county, method = 'ld_NPP', param = 'annualNPP', stat = 'median', startDate = '1986-01-01', endDate = '2016-01-01')

Now we can vizualize this Image with viz(). The scale argument in this function is a way to get a close guess at a min/max argument. If you already have an idea of a min/max value (e.g. Normalized Difference: 0-1) then just put that into the arguments and viz() will not run getInfo(). This approach makes visualising much faster.

npp %>% viz(scale = 250)


Ok, now that we’ve got an idea of the area let’s see what it would look like if we reduced this area of interest. To do that we’ll use the rr() function. This function uses any GEE Feature Collection or sf object to reduce regions to common statistics, e.g. mean, max, min, median, stdDev and sum. Scale matters in this situation! So, make sure you understand what the underlying scale is. Sometimes I’ll use a big scale just to see a coarse depiction and then when I go to the analyis I’ll reduce that scale, up the tileScale and run lazy = TRUE.

npp %>% rr(scale = 250, leaflet = TRUE)


Maybe we want to see how this region looked over time and not as static statistics? Well, we can use the `band()` function to do this. This function takes each year and `toBands()` the ImageCollection. From there, using rgee `ee_extract()` we can then convert to table values. This is an expensive function and you can use `lazy = TRUE`. This will split the object into 10 groups and run a for loop in the background in sequential. Future developments will hopefully make this parallel.
npp %>% band(scale = 1000, ggplot = TRUE)


explorergee's People

Contributors

jlerickson avatar joshualerickson avatar zackarno avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

explorergee's Issues

stat = 'stdDev' with get_*()'s

Need to fix or somehow adapt 'stdDev' to be able to reduce multiple bands. Right now, it works if param = 'NDVI' one band only, if not then it won't reduce. I think this has to do with using data$reduce(ee$Reducer$stdDev()) in data_stat().

I want to add value to list to ee.Image.

I want to add value to list to ee.Image.

MODDAY_ext_lst <- select(MODDAY_ext, LST_Day_1km)
print(MODDAY_ext_lst)
class(MODDAY_ext_lst)

Result:

class(MODDAY_ext_lst)
[1] "data.frame"

typeof(MODDAY_ext_lst)
[1] "list"

cal_value <- na_interpolation(MODDAY_ext_lst, option = "linear", maxgap = Inf)
class(cal_value)
typeof(cal_value)

Result:

class(MODDAY_ext)
[1] "data.frame"

typeof(MODDAY_ext)
[1] "list"

MODDAY_ext["LST_Day_1km"] <- cal_value["LST_Day_1km"]
print(MODDAY_ext)
class(MODDAY_ext)
typeof(MODDAY_ext)

Result:

class(MODDAY_ext)
[1] "data.frame"

typeof(MODDAY_ext)
[1] "list"

I want to add the created parameter(MODDAY_ext) to 'ee.Image' file. How can I do? Thank you.

values not returned for bands SWIR1 and SWIR2 for temporal = 'year_month'

Hi,

Been exploring the package and really enjoy the ease with which data can be pulled from gee. Found a possible bug in the band() function for the bands SWIR1 / SWIR2 and temporal = 'year_month' . Below is a quick example. All other combinations appear to work .

library(exploreRGEE)
library(rgee)
library(ggplot2)

ee_Initialize()

huc <- exploreRGEE::huc

ts <- get_landsat(huc, method = 'ts', startDate = '2019-01-01', endDate = '2020-12-31', c.low = 1, c.high = 12)

nothing returned for SWIR1 or SWIR2 for year_month

ts %>% band(band = 'SWIR2', scale = 250, ggplot = TRUE, temporal = 'year_month')

other temporal periods work, e.g.

ts %>% band(band = 'SWIR2', scale = 250, ggplot = TRUE, temporal = 'monthly')

other bands work, e.g.

ts %>% band(band = 'Green', scale = 250, ggplot = TRUE, temporal = 'year_month')

sessionInfo()

R version 4.0.4 (2021-02-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252 LC_MONETARY=English_Australia.1252
[4] LC_NUMERIC=C LC_TIME=English_Australia.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] ggplot2_3.3.5.9000 exploreRGEE_0.1 rgee_1.1.3

loaded via a namespace (and not attached):
[1] httr_1.4.2 tidyr_1.2.0 splines_4.0.4 jsonlite_1.8.0 shiny_1.7.1
[6] assertthat_0.2.1 askpass_1.1 sp_1.4-6 pillar_1.7.0 lattice_0.20-41
[11] glue_1.6.2 reticulate_1.24 digest_0.6.29 promises_1.2.0.1 colorspace_2.0-3
[16] htmltools_0.5.2 httpuv_1.6.5 Matrix_1.4-0 pkgconfig_2.0.3 httpcode_0.3.0
[21] purrr_0.3.4 xtable_1.8-4 scales_1.1.1 processx_3.5.0 later_1.3.0
[26] tibble_3.1.6 openssl_2.0.0 proxy_0.4-26 googledrive_2.0.0 mgcv_1.8-39
[31] farver_2.1.0 generics_0.1.2 ellipsis_0.3.2 withr_2.5.0 geojsonio_0.9.4
[36] lazyeval_0.2.2 cli_3.1.0 magrittr_2.0.2 crayon_1.5.1 mime_0.12
[41] maptools_1.1-3 ps_1.6.0 fs_1.5.2 fansi_1.0.3 nlme_3.1-155
[46] foreign_0.8-82 class_7.3-20 geojsonsf_2.0.2 tools_4.0.4 gargle_1.2.0
[51] lifecycle_1.0.1 geojson_0.3.4 stringr_1.4.0 V8_4.1.0 munsell_0.5.0
[56] compiler_4.0.4 e1071_1.7-9 jqr_1.2.3 rlang_1.0.2 classInt_0.4-3
[61] units_0.8-0 grid_4.0.4 rstudioapi_0.13 htmlwidgets_1.5.4 crosstalk_1.2.0
[66] labeling_0.4.2 gtable_0.3.0 DBI_1.1.2 curl_4.3 R6_2.5.1
[71] lubridate_1.8.0 knitr_1.37 dplyr_1.0.8 fastmap_1.1.0 rgeos_0.5-9
[76] utf8_1.2.2 KernSmooth_2.23-20 stringi_1.7.6 crul_1.2.0 Rcpp_1.0.8.3
[81] vctrs_0.4.0 sf_1.0-7 png_0.1-7 leaflet_2.1.1 tidyselect_1.1.2
[86] xfun_0.30

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.