rgee is a binding package for calling Google Earth Engine API from within R. Additionally, several functions have been implemented to make simple the connection with the R spatial ecosystem. The
rgee package structure has been inspired by the TensorFlow R package.
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.
Earth Engine Python API:
Quite similar, isn’t it?. However, there are additional smaller changes that you must consider when you use Google Earth Engine with R. Please check the consideration section before start coding!
rgee package from GitHub is quite simple, you just have to run in your R console as follows:
After that, in your preferred browser, run:
Prior to using
rgee you will need to install a Python version higher than 3.5 in your system.
rgee counts with a installation module, use it to quickly set up the external dependencies of
library(rgee) # 1. Initialize rgee with ee_Initialize(). If there is no any Python environment, miniconda # will be installed by default. ee_Initialize() # 2. Create a Python environment, e.g. ee. ee_create_pyenv(env = "ee") # 3. Find all Python environments in the system. ee_discover_pyenvs() # 4. Set a Python environment (e.g. ee) and restart R to see changes. e.g ee_set_pyenv(python_path = '/home/user/.virtualenvs/ee/bin/python', python_env = 'ee') # 5. Install Python package dependencies ee_install_python_packages() # 6. Install Python package dependencies ee_Initialize()
Additionally, use these functions, as many times as you want, for checking user info and sanity of credentials, drivers and Python packages.
Use this function to clean the system variables set in ee_set_pyenv.
Also, consider checking the setup section for major information to customizing Python installation.
rgeefunctions have the prefix ee_. Auto-completion is your friend :).
rgeeis “pipe-friendly”, we re-exports %>%, but
rgeedoes not require its use.
ee_pyfuncbefore passing them to the Earth Engine Web REST API. This is not compulsory, but it will help reduce possible bugs 🐛.
Authenticate and Initialize the Earth Engine R API.
Adds a band containing image date as years since 1991.
Map the time band creation helper over the night-time lights collection.
Compute a linear fit over the series of values at each pixel, visualizing the y-intercept in green, and positive/negative slopes as red/blue.
Create a interactive visualization!
sf and authenticate and initialize the Earth Engine R API.
Map each image from 2001 to extract the monthly precipitation (Pr) from the Terraclimate dataset
Extract monthly precipitation values from the Terraclimate ImageCollection through
ee_extract works similar to
raster::extract you just need to define: the ImageCollection object (x), the geometry (y), and a function to summarize the values (fun).
Create a simple plot!
reticulate is an R package designed to allow a seamless interoperability between R and Python. When an Earth Engine process is created in R, firstly,
reticulate transforms this piece of code to Python. Once the Python code is obtained, the
Earth Engine Python API transform the request to a
JSON format. Finally, the query (in JSON) is received by the Google Earth Engine Platform thanks to a Web REST API. The response will follow the same path. If you are searching a way to interact with the Earth Engine Asset (EEA),
rgee offers also functions to batch upload(download) spatial objects. Additionally, you could easily manage EEA through the ee_manage_* interface.
Please note that the
rgee project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
👍🎉 First off, thanks for taking the time to contribute! 🎉👍 Please review our Contributing Guide.
Most of the
rgee functionalities were based in the following third-party R/Python packages: