Git Product home page Git Product logo

rgeeextra's Introduction

rgee Examples โœ๏ธ ๐Ÿ“™

A collection of tutorials, guides and examples to learn to use Google Earth Engine with R. The material presented here is a compilation of Earth Engine guides, earthengine-py-notebooks, EEwPython, and user contributions ๐Ÿ™‡. Note that access to Google Earth Engine is only available to registered users.



Contributing Guide

First of all, thanks for considering contributing to rgee-examples! ๐Ÿ‘ It's people like you that make it rewarding for us - the project maintainers - to work on rgee-examples. ๐Ÿ˜Š rgee-examples is an open source project, maintained by people who care. We are not directly funded to do so.

To contribute consider to follow the next steps:

  1. Fork r-earthengine.github.io and clone it to your computer. To learn more about this process, see this guide.
  2. If you have forked and cloned the project before and it has been a while since you worked on it, pull changes from the original repo to your clone by using git pull upstream master.
  3. Open the RStudio project file (examples.Rproj).
  4. Make your changes:
    • Create a Rmarkdown (demo.Rmd).
    • Write your post.
    • Add these items (mandatory) to the Rmarkdown header.
      • title: Title of the post.
      • author: Name of the person who writes the post.
      • date: Date the post is written.
      • categories: Category for the post (only one category is recommended).
      • tags: Tags for the post (up to a maximum of three labels is recommended).
      • thumbnail: Thumbnail image to be displayed on the main website.
      • url: The path to the resource.
    • See an example with the desired structure here.
  5. Commit and push your changes.
  6. Submit a pull request.

rgeeextra's People

Contributors

csaybar avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

rgeeextra's Issues

readme

Hey @csaybar great work as always! I noticed a few things when I started working with the package in regards to the Readme and thought I'd give a shout. Just a few things with the example. So nice to be able to index now and use the operators! Take care.

library(rgee)

ee_Initialize()

img <- ee$Image("LANDSAT/LC08/C01/T1_SR/LC08_038029_20180810")
ndvi <- (img[["B5"]] - img[["B4"]])/(img[["B5"]] + img[["B4"]])**2
names(ndvi) <- "pow_ndvi"

Map$centerObject(img,zoom=12)
Map$addLayer(img)

potential edits

library(rgee)
library(rgeeExtra) #add library call

ee_Initialize()

img <- ee$Image("LANDSAT/LC08/C01/T1_SR/LC08_038029_20180810")
ndvi <- (img[["B5"]] - img[["B4"]])/(img[["B5"]] + img[["B4"]])**2
names(ndvi) <- "pow_ndvi"

# here just add ndvi instead of image and also some visParams for the image with power.
Map$centerObject(ndvi,zoom=12)
Map$addLayer(ndvi, visParams = list(min = -0.001, max = 0.001)

Issue with py module ee_extra

Hi,
I'm trying to use the rgeeExtra::module function to import a .js module. Here's my code:

library(rgee)
library(rgeeExtra)
ee_Initialize("gtyreegee")
x <- "users/gtyreegee/MODIS_006_MCD19A2:Modules/RAP_LC_Bins_Module.js"
getRAPstrata <- module(x)

When I run the code, I get the error: "Python module ee_extra was not found." However, I checked my py conda environment and ee_extra is installed as:
ee_extra; 0.0.12; pyhd8ed1ab_0; conda-forge

Has this issue come up before, and if so, how was it solved?

I'm using rgee version 1.1.2, rgeeExtra version 0.0.1 in RStudio 1.4.1717.

rgeeExtra::module() returns 404 error

Hey there! Having initialized GEE successfully, I cannot seem to load js modules using rgeeExtra::module(). My problem is similar to the one described in issue 6, but since that has remained unchanged for about a year, I opened this new issue. Here's a reprex:

library(rgee)
library(rgeeExtra)
library(reticulate)

ee_Initialize() # initialize gee
#> โ”€โ”€ rgee 1.1.5 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ earthengine-api 0.1.323 โ”€โ”€ 
#>  โœ” user: not_defined
#>  โœ” Initializing Google Earth Engine: โœ” Initializing Google Earth Engine:  DONE!
#>  โœ” Earth Engine account: users/MathiasWeidinger 
#> โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

reticulate::py_install(packages=c("regex", "ee_extra", "jsbeautifier")) # install necessary python packages
#> Using virtual environment '/home/madmat/.virtualenvs/rgee' ...
#> + '/home/madmat/.virtualenvs/rgee/bin/python' -m pip install --upgrade --no-user 'regex' 'ee_extra' 'jsbeautifier'

x <- "users/andreim/geeMonitor:monitor.js"

engine <- rgeeExtra::module(x)
#> HTTP Error 404: Not Found

I tried loading in other modules with the same result. Still, from my side everything seems to be up to date and otherwise rgee is working as expected. Any ideas what might be going wrong?

Cheers!

Trouble with rgeeExtra install

Hi, I want to use rgeeExtra to import Javascript modules from GEE, as described in r-spatial/rgee issue #155 (r-spatial/rgee#155). I have successfully downloaded the required version of reticulate (1.22.9000) but I am having difficulty downloading the rgeeExtra package. Below is my code and the output.

remotes::install_github("r-earthengine/rgeeExtra")

Downloading GitHub repo r-earthengine/rgeeExtra@HEAD
Error: Failed to install 'rgeeExtra' from GitHub:
Git does not seem to be installed on your system.
In addition: Warning message:
In readLines(file) :
incomplete final line found on 'C:\Users\Gtyree\AppData\Local\Temp\RtmpSSb4xZ\remotesd228626324ba/r-earthengine-rgeeExtra-a14ee7c/.gitmodules'

I attempted to solve the issue by installing Git, but after I did that I began to experience the issue described in r-spatial/rgee issue #91 (r-spatial/rgee#91). It's possible that the problem was unrelated to Git, but was only solved after I both uninstalled Git and ran this code:

library(rgee)
library(reticulate)
earthengine_python <- Sys.getenv("EARTHENGINE_PYTHON", unset = NA)
Sys.setenv(RETICULATE_PYTHON = earthengine_python)
reticulate::py_config()

Is there a way to install rgeeExtra that doesn't require Git? I have also tried devtools::install_github("r-earthengine/rgeeExtra") but received the same error message.

I am using RStudio v. 1.4.1717 on a Windows 10 computer.

rgeeExtra - "has no attribute" error

Hi csaybar,

I can not make it to work, every time I tried I get this kind of error. rgee works great.

Error in py_get_attr_impl(x, name, silent) :
AttributeError: type object 'Image' has no attribute 'getDOI'
Run reticulate::py_last_error() for details.

I's like so with other like "spectralIndex" e.g
Are there any python dependencies for rgeeExtra to work?. Do you have any idea of what is the problem.

problem rgeeExtra

with rgee Initialized:

library(rgee)
ee_Initialize( drive =T)

โ”€โ”€ rgee 1.1.5 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ earthengine-api 0.1.323 โ”€โ”€
โœ” user: not_defined
โœ” Google Drive credentials: FOUND
โœ” Initializing Google Earth Engine: DONE!
โœ” Earth Engine account: users/xxxxxxx
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
I installed remotes::install_github("r-earthengine/rgeeExtra")

everything worked fine.

but no function could be find:

>library(rgeeExtra)
> ee_ImageCollection_scaleAndOffset()
Error in ee_ImageCollection_scaleAndOffset() : 
could not find function "ee_ImageCollection_scaleAndOffset"

> ee_ImageCollection_spectralIndex()
Error in ee_ImageCollection_spectralIndex() : 
  could not find function "ee_ImageCollection_spectralIndex"

version
platform x86_64-w64-mingw32
arch x86_64
os mingw32
crt ucrt
system x86_64, mingw32
status
major 4
minor 2.2
year 2022
month 10
day 31
svn rev 83211
language R
version.string R version 4.2.2 (2022-10-31 ucrt)
nickname Innocent and Trusting

translate fail in image overview - I

CASE:

var loadedImage = ee.Image('JAXA/ALOS/AW3D30/V2_2');
var first = ee.ImageCollection('COPERNICUS/S2_SR')
                .filterBounds(ee.Geometry.Point(-70.48, 43.3631))
                .filterDate('2019-01-01', '2019-12-31')
                .sort('CLOUDY_PIXEL_PERCENTAGE')
                .first();
var uri = 'gs://gcp-public-data-landsat/LC08/01/001/002/' +
    'LC08_L1GT_001002_20160817_20170322_01_T2/' +
    'LC08_L1GT_001002_20160817_20170322_01_T2_B5.TIF';
var cloudImage = ee.Image.loadGeoTIFF(uri);

GOT:

 Error in py_call_impl(callable, dots$args, dots$keywords) : 
 InvalidInput: Cannot parse: 17:54: uri = 'gs:#gcp-public-data-landsat/LC08/01/001/002/' + 

Failing to get spectral indexes

Hello,

I am trying to get spectral indexes using the function ee$Image$spectralIndex() without success.

# Load libraries
library(rgee)
library(rgeeExtra)

# Initialize Earth Engine
ee_Initialize()
extra_Initialize()

## Attempt 1: copied from rgee book ----

ds <- 'LANDSAT/LC08/C01/T1_SR'

ee$ImageCollection(ds) %>% 
  ee_ImageCollection_scaleAndOffset() %>% 
  ee_ImageCollection_spectralIndex(c('NDVI', 'GNDVI', 'NDSI'))

# Error in ee_ImageCollection_spectralIndex(., c("NDVI", "GNDVI", "NDSI")) : 
#   could not find function "ee_ImageCollection_spectralIndex"

## Attempt 2: copied from function reference ----

s2_indices <- ee$ImageCollection("COPERNICUS/S2_SR") %>%
  ee$ImageCollection$first() %>%
  ee$Image$preprocess()%>%
  ee$Image$spectralIndex(c("NDVI", "SAVI"))

# Error in EEextra_PYTHON_PACKAGE$QA : 
#   RuntimeError: $ operator is invalid for atomic vectors

## Attempt 3 ----

## Get an image (works)
s2_img <- ee$ImageCollection("COPERNICUS/S2_SR") %>% 
  ee$ImageCollection$first()

## Preprocess (no not work)
ee$Image$preprocess(s2_img)

#Error in EEextra_PYTHON_PACKAGE$Spectral : 
#  RuntimeError: $ operator is invalid for atomic vectors

## Get spectral indexes (do not work)
ee$Image$spectralIndex(s2_img)

#Error in EEextra_PYTHON_PACKAGE$Spectral : 
#  RuntimeError: $ operator is invalid for atomic vectors

I am working with R 4.3.1, RStudio 2023.06.1, rgee version 1.1.7 and rgeeExtra development version.

Issue with REGEX

Hi!
Amazing features. RgeeExtra is exactly what I have searching for.

But I am facing something similar to gltyree into other issue description.
When i run the example:

library(rgee)
library(rgeeExtra)
library(reticulate)
ee_Initialize()
x <- "users/sofiaermida/landsat_smw_lst:modules/Landsat_LST.js"
LandsatLST <- module(x)

I get:

LandsatLST <- module(x)
Installing Js module in: C:/Users/marib/Documents/R/win-library/4.1/rgeeExtra/ee_extra/ee_extra/ee-sources
Error in py_call_impl(callable, dots$args, dots$keywords) :
ImportError: "regex" is not installed. Please install "regex" -> "pip install regex"

#traceback
7. stop(structure(list(message = "ImportError: "regex" is not installed. Please install "regex" -> "pip install regex"\n",
call = py_call_impl(callable, dots$args, dots$keywords),
cppstack = NULL), class = c("Rcpp::exception", "C++Error",
"error", "condition")))
6. EEextra_PYTHON_PACKAGE$require(x)
5. value[3L]
4. tryCatchOne(expr, names, parentenv, handlers[[1L]])
3. tryCatchList(expr, classes, parentenv, handlers)
2. tryCatch(expr = EEextra_PYTHON_PACKAGE$require(x), error = function(e) {
EEextra_PYTHON_PACKAGE$install(x = x, update = upgrade, quiet = TRUE)
if (!quiet) {message(sprintf("Installing Js module in: %s", ee_install$"_get_ee_sources_path"())) ...

  1. module(x)

But I have installed Regex:
#Anaconda prompt

(base) C:\Users\marib>pip install regex
Requirement already satisfied: regex in c:\users\marib\appdata\local\r-miniconda\lib\site-packages (2022.6.2)

I'm a using rgee 1.1.3, rgeeExtra 0.0.1, reticulate 1.25, R version 4.1.3, RStudio 2022.02.0+443, Windows 10.
Do you know how to fix it? I think this is something to do with the folder where REGEX is installed but I don't know how to deal with it.

Thanks a lot.

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.