Title: | Extensions for 'rgee' |
---|---|
Description: | High-level API to process Google Earth Engine (GEE) raster (ee.Image and ee.ImageCollection) and vector data (ee.Geometry, ee.Feature, and ee.FeatureCollection). Popular Third-party GEE algorithms are re-coded from Javascript and Python to R. |
Authors: | Cesar Aybar [aut, cre] , David Montero [ctb] , Lesly Bautista [ctb] , Marc Choisy [ctb] |
Maintainer: | Cesar Aybar <[email protected]> |
License: | Apache License (>= 2) |
Version: | 0.1.0 |
Built: | 2024-11-24 05:56:22 UTC |
Source: | https://github.com/r-earthengine/rgeeExtra |
Google Earth Engine (Gorelick et al., 2017) is a cloud computing platform
designed for planetary-scale environmental data analysis that only can be
accessed via the Earth Engine code editor, third-party web apps, and the
JavaScript and Python client libraries. rgee
is a non-official
client library for R that uses reticulate
to wrap the Earth Engine
Python API and provide R users with a familiar interface, rapid development
features, and flexibility to analyze data using open-source, R third-party
packages.
The package implements and supports:
Math operators
Maintainer: Cesar Aybar [email protected] (ORCID)
Other contributors:
David Montero [email protected] (ORCID) [contributor]
Lesly Bautista [email protected] (ORCID) [contributor]
Marc Choisy [email protected] (ORCID) [contributor]
Useful links:
Report bugs at https://github.com/r-earthengine/rgeeExtra/issues
Extract parts of and EE FeatureCollection
## S3 method for class 'ee.featurecollection.FeatureCollection' x[[index]]
## S3 method for class 'ee.featurecollection.FeatureCollection' x[[index]]
x |
ee$FeatureCollection. |
index |
Integer. Index specifying elements to extract or replace. |
An ee$FeatureCollection
## Not run: library(rgee) library(rgeeExtra) library(sf) ee_Initialize(gcs = TRUE, drive = TRUE) extra_Initialize() # Define a Image or ImageCollection: Terraclimate fc_tiger <- ee$FeatureCollection('TIGER/2016/Roads') fc_tiger_subset <- fc_tiger[[1:100]] Map$centerObject(fc_tiger_subset) Map$addLayer(fc_tiger_subset) ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) library(sf) ee_Initialize(gcs = TRUE, drive = TRUE) extra_Initialize() # Define a Image or ImageCollection: Terraclimate fc_tiger <- ee$FeatureCollection('TIGER/2016/Roads') fc_tiger_subset <- fc_tiger[[1:100]] Map$centerObject(fc_tiger_subset) Map$addLayer(fc_tiger_subset) ## End(Not run)
Return the element at a specified position in an Earth Engine Image or ImageCollection
ee_get(ee_c, index = 0)
ee_get(ee_c, index = 0)
ee_c |
ImageCollection or FeatureCollection. |
index |
Numeric. Specified position. |
Depending of ee_c
can return either an ee$FeatureCollection
or ee$ImageCollection
.
## Not run: library(rgee) library(sf) ee_Initialize() nc <- st_read(system.file("shape/nc.shp", package = "sf")) %>% st_transform(4326) %>% sf_as_ee() ee_s2 <- ee$ImageCollection("COPERNICUS/S2")$ filterDate("2016-01-01", "2016-01-31")$ filterBounds(nc) ee_s2$size()$getInfo() # 126 # Get the first 5 elements ee_get(ee_s2, index = 0:4)$size()$getInfo() # 5 ## End(Not run)
## Not run: library(rgee) library(sf) ee_Initialize() nc <- st_read(system.file("shape/nc.shp", package = "sf")) %>% st_transform(4326) %>% sf_as_ee() ee_s2 <- ee$ImageCollection("COPERNICUS/S2")$ filterDate("2016-01-01", "2016-01-31")$ filterBounds(nc) ee_s2$size()$getInfo() # 126 # Get the first 5 elements ee_get(ee_s2, index = 0:4)$size()$getInfo() # 5 ## End(Not run)
Masks clouds and shadows in an ee.Image. Valid just for Surface Reflectance products. This function may mask water as well as clouds for the Sentinel-3 Radiance product.
`ee$Image$Extra_maskClouds(x, ...)`
`ee$Image$Extra_maskClouds(x, ...)`
x |
An ee$Image to be processed for cloud and shadow masking. |
... |
Additional arguments for cloud and shadow masking. See details for more information. |
The ...
argument can include the following:
methodCharacter. The method to mask clouds. Options: "cloud_prob" and "qa".
probNumeric. Cloud probability threshold, between 0 and 100. Valid for 'cloud_prob' method. Default 60.
maskCirrusLogical. Whether to mask cirrus clouds. Valid for 'qa' method. Default TRUE.
maskShadowsLogical. Whether to mask cloud shadows. Default TRUE.
scaledImageLogical. If TRUE, scale pixel values to <0,1>. Default FALSE.
darkNumeric. NIR threshold for potential cloud shadows, between 0-1. Default 0.15.
cloudDistNumeric. Max distance in meters to search for cloud shadows from cloud edges. Default 1000m.
bufferNumeric. Distance in meters to dilate cloud and shadow objects. Default 250m.
cdiNumeric. Cloud Displacement Index threshold, between <-1, 1>. Default NULL.
For more information on parameters and methods, refer to relevant cloud masking literature and tutorials.
ee$Image with a Cloud-shadow masked image.
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() img <- ee$ImageCollection("COPERNICUS/S2_SR") %>% ee$ImageCollection$first() %>% ee$Image$Extra_maskClouds(prob = 75,buffer = 300,cdi = -0.5) names(img) ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() img <- ee$ImageCollection("COPERNICUS/S2_SR") %>% ee$ImageCollection$first() %>% ee$Image$Extra_maskClouds(prob = 75,buffer = 300,cdi = -0.5) names(img) ## End(Not run)
Matches the histogram of one image (source) to that of another image (target).
`ee$Image$Extra_matchHistogram(x, ...)`
`ee$Image$Extra_matchHistogram(x, ...)`
x |
ee$Image to adjust. |
... |
Additional arguments for histogram matching. See details for more information. |
The ...
argument can include the following:
targetee$Image. The target image to match.
bandsDictionary. Band names to match, with source bands as keys and target bands as values.
geometryee$Geometry. The region to match histograms in that overlaps both images. Default is NULL.
maxBucketsInteger. The maximum number of buckets to use when building histograms. Default 256.
These parameters allow for detailed customization of the histogram matching process.
The adjusted image containing the matched source bands.
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() source <- ee$Image("LANDSAT/LC08/C01/T1_TOA/LC08_047027_20160819") target <-ee$Image("LANDSAT/LE07/C01/T1_TOA/LE07_046027_20150701") bands <- list("B4"="B3", "B3"="B2", "B2"="B1") matched <- ee$Image$Extra_matchHistogram(source, target, bands) names(matched) ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() source <- ee$Image("LANDSAT/LC08/C01/T1_TOA/LC08_047027_20160819") target <-ee$Image("LANDSAT/LE07/C01/T1_TOA/LE07_046027_20150701") bands <- list("B4"="B3", "B3"="B2", "B2"="B1") matched <- ee$Image$Extra_matchHistogram(source, target, bands) names(matched) ## End(Not run)
Computes one or more spectral indices for an ee$Image or an ee$ImageCollection object.
`ee$Image$Extra_spectralIndex(x, ...)`
`ee$Image$Extra_spectralIndex(x, ...)`
x |
An ee$Image or an ee$ImageCollection to compute indices on. |
... |
Additional arguments passed to the underlying spectral index computation function. See details for a complete list of possible arguments. |
The ...
argument can include any of the following:
indexCharacter. Index or list of indices to compute. Options include 'vegetation', 'burn', 'water', 'snow', 'drought', 'urban', 'kernel', and 'all'. Default 'NDVI'.
GNumeric. Gain factor for 'EVI'. Default 2.5.
C1, C2Numerics. Coefficients for aerosol resistance in 'EVI'. Defaults are 6.0 and 7.5.
LNumeric. Canopy background adjustment for 'EVI' or 'SAVI'. Default 1.0.
cexpNumeric. Coefficient for 'OCVI'. Default 1.16.
nexpNumeric. Exponent for 'GDVI'. Default 2.0.
alphaNumeric. Weighting coefficient for 'WDRVI'. Default 0.1.
slope, interceptNumerics. Soil line slope and intercept. Defaults are 1.0 and 0.0.
gammaNumeric. Weighting coefficient for 'ARVI'. Default 1.0.
kernelCharacter. Kernel type for kernel indices. Options are 'linear', 'RBF', and 'poly'. Default 'RBF'.
sigmaCharacter or Numeric. Length-scale parameter for RBF kernel. Default '0.5 * (a + b)'.
pNumeric. Kernel degree for polynomial kernel. Default 2.0.
cNumeric. Free parameter for polynomial kernel. Default 1.0.
onlineLogical. Whether to retrieve the most recent list of indices online. Default FALSE.
dropLogical. If TRUE, drop the image bands after calculation. Default TRUE.
For a complete list of indices and their parameters, please refer to the spectral indices documentation.
An ee$Image or an ee$ImageCollection with the computed spectral index, or indices, as new bands.
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() s2_indices <- ee$ImageCollection("COPERNICUS/S2_SR") %>% ee$ImageCollection$first() %>% ee$Image$Extra_preprocess() %>% ee$Image$Extra_spectralIndex(c("NDVI", "SAVI")) names(s2_indices) # "NDVI" "SAVI" ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() s2_indices <- ee$ImageCollection("COPERNICUS/S2_SR") %>% ee$ImageCollection$first() %>% ee$Image$Extra_preprocess() %>% ee$Image$Extra_spectralIndex(c("NDVI", "SAVI")) names(s2_indices) # "NDVI" "SAVI" ## End(Not run)
Gets the closest ee$Image to a specified date from an ee$ImageCollection.
`ee$ImageCollection$Extra_closest(x, ...)`
`ee$ImageCollection$Extra_closest(x, ...)`
x |
ee$ImageCollection from which to get the closest image to the specified date. |
... |
Additional arguments for finding the nearest image. See details for more information. |
The ...
argument can include the following:
dateee$Date or R date object. Date of interest for searching the closest image.
toleranceNumeric. Filters the collection within a range of (date - tolerance, date + tolerance). Default 1.
unitCharacter. Units for tolerance. Options include "year", "month", "week", "day", "hour", "minute", "second". Default "month".
These parameters allow for precise control over how the closest image is determined.
An ee$Image closest to the specified date.
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() roi <- ee$Geometry$Point(c(-79, -12)) ee$ImageCollection$Dataset$MODIS_006_MCD12Q1 %>% ee$ImageCollection$Extra_closest("2020-10-15", 2, "year") %>% ee$ImageCollection$first() %>% Map$addLayer() ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() roi <- ee$Geometry$Point(c(-79, -12)) ee$ImageCollection$Dataset$MODIS_006_MCD12Q1 %>% ee$ImageCollection$Extra_closest("2020-10-15", 2, "year") %>% ee$ImageCollection$first() %>% Map$addLayer() ## End(Not run)
Get the properties names of FeatureCollection object
## S3 method for class 'ee.feature.Feature' names(x)
## S3 method for class 'ee.feature.Feature' names(x)
x |
an EE FeatureCollection object. |
A vector representing the property names of the ee$FeatureCollection object
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() fc <- ee$FeatureCollection('WRI/GPPD/power_plants') fc$propertyNames()$getInfo() ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() fc <- ee$FeatureCollection('WRI/GPPD/power_plants') fc$propertyNames()$getInfo() ## End(Not run)
Get the names of the properties of an Earth Engine ImageCollection object.
## S3 method for class 'ee.imagecollection.ImageCollection' names(x)
## S3 method for class 'ee.imagecollection.ImageCollection' names(x)
x |
an EE ImageCollection object. |
A vector with the property names of ee$ImageCollection object
## Not run: library(rgeeExtra) library(rgee) ee_Initialize() # Initialize the Google Earth Engine API connection extra_Initialize() # Initialize the extended functionalities of rgeeExtra ic <- ee$ImageCollection("COPERNICUS/S2_SR") %>% ee$ImageCollection$filterDate("1999-01-01", "1999-01-02") names(ic) ## End(Not run)
## Not run: library(rgeeExtra) library(rgee) ee_Initialize() # Initialize the Google Earth Engine API connection extra_Initialize() # Initialize the extended functionalities of rgeeExtra ic <- ee$ImageCollection("COPERNICUS/S2_SR") %>% ee$ImageCollection$filterDate("1999-01-01", "1999-01-02") names(ic) ## End(Not run)
Add text to a GIF (magick-image object). This function is a wrapper around image_annotate.
ee_utils_gif_annotate( image, text, gravity = "northwest", location = "+0+0", degrees = 0, size = 20, font = "sans", style = "normal", weight = 400, kerning = 0, decoration = NULL, color = NULL, strokecolor = NULL, boxcolor = NULL )
ee_utils_gif_annotate( image, text, gravity = "northwest", location = "+0+0", degrees = 0, size = 20, font = "sans", style = "normal", weight = 400, kerning = 0, decoration = NULL, color = NULL, strokecolor = NULL, boxcolor = NULL )
image |
magick image object returned by |
text |
character vector of length equal to 'image' or length 1 |
gravity |
string with gravity value from gravity_types. |
location |
geometry string with location relative to |
degrees |
rotates text around center point |
size |
font-size in pixels |
font |
string with font family such as |
style |
value of style_types for example |
weight |
thickness of the font, 400 is normal and 700 is bold. |
kerning |
increases or decreases whitespace between letters |
decoration |
value of decoration_types for example |
color |
a valid color string such as
|
strokecolor |
a color string adds a stroke (border around the text) |
boxcolor |
a color string for background color that annotation text is rendered on. |
A magick-image object
Jeroen Ooms
Other GIF functions:
ee_utils_gif_creator()
,
ee_utils_gif_save()
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() col <- ee$ImageCollection("JRC/GSW1_1/YearlyHistory")$map(function(img) { year <- img$date()$get("year") yearImg <- img$gte(2)$multiply(year) despeckle <- yearImg$connectedPixelCount(15, TRUE)$eq(15) yearImg$updateMask(despeckle)$selfMask()$set("year", year) }) appendReverse <- function(col) col$merge(col$sort('year', FALSE)) # ----------------------------------- # 1 Basic Animation - Ucayali Peru # ----------------------------------- bgColor = "FFFFFF" # Assign white to background pixels. riverColor = "0D0887" # Assign blue to river pixels. ## 1.1 Create the dataset annualCol = col$map(function(img) { img$unmask(0)$ visualize(min = 0, max = 1, palette = c(bgColor, riverColor))$ set("year", img$get("year")) }) basicAnimation <- appendReverse(annualCol) ## 1.2 Set video arguments aoi <- ee$Geometry$Rectangle(-74.327, -10.087, -73.931, -9.327) videoArgs = list( dimensions = 600, # Max dimension (pixels), min dimension is proportionally scaled. region = aoi, framesPerSecond = 10 ) ## 1.2 Download, display and save the GIF! animation <- ee_utils_gif_creator(basicAnimation, videoArgs, mode = "wb") get_years <- basicAnimation$aggregate_array("year")$getInfo() animation %>% ee_utils_gif_annotate("Ucayali, Peru") %>% ee_utils_gif_annotate(get_years, size = 15, location = "+90+40", boxcolor = "#FFFFFF") %>% ee_utils_gif_annotate("created using {magick} + {rgee}", size = 15, font = "sans",location = "+70+20") -> animation_wtxt gc(reset = TRUE) ee_utils_gif_save(animation_wtxt, path = paste0(tempfile(), ".gif")) ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() col <- ee$ImageCollection("JRC/GSW1_1/YearlyHistory")$map(function(img) { year <- img$date()$get("year") yearImg <- img$gte(2)$multiply(year) despeckle <- yearImg$connectedPixelCount(15, TRUE)$eq(15) yearImg$updateMask(despeckle)$selfMask()$set("year", year) }) appendReverse <- function(col) col$merge(col$sort('year', FALSE)) # ----------------------------------- # 1 Basic Animation - Ucayali Peru # ----------------------------------- bgColor = "FFFFFF" # Assign white to background pixels. riverColor = "0D0887" # Assign blue to river pixels. ## 1.1 Create the dataset annualCol = col$map(function(img) { img$unmask(0)$ visualize(min = 0, max = 1, palette = c(bgColor, riverColor))$ set("year", img$get("year")) }) basicAnimation <- appendReverse(annualCol) ## 1.2 Set video arguments aoi <- ee$Geometry$Rectangle(-74.327, -10.087, -73.931, -9.327) videoArgs = list( dimensions = 600, # Max dimension (pixels), min dimension is proportionally scaled. region = aoi, framesPerSecond = 10 ) ## 1.2 Download, display and save the GIF! animation <- ee_utils_gif_creator(basicAnimation, videoArgs, mode = "wb") get_years <- basicAnimation$aggregate_array("year")$getInfo() animation %>% ee_utils_gif_annotate("Ucayali, Peru") %>% ee_utils_gif_annotate(get_years, size = 15, location = "+90+40", boxcolor = "#FFFFFF") %>% ee_utils_gif_annotate("created using {magick} + {rgee}", size = 15, font = "sans",location = "+70+20") -> animation_wtxt gc(reset = TRUE) ee_utils_gif_save(animation_wtxt, path = paste0(tempfile(), ".gif")) ## End(Not run)
Create an GIF (as a magick-image object) from a EE
ImageCollection. Note: Animations can only be created when ImageCollections
is composed by RGB or RGBA image. This can be done by mapping
a visualization function onto an ImageCollection
(e.g. ic$map(function(img) img$visualize(...))
)
or specifying three bands in parameters argument (See examples).
ee_utils_gif_creator is a
wrapper around ee$ImageCollection$getVideoThumbURL
.
ee_utils_gif_creator(ic, parameters, quiet = FALSE, ...)
ee_utils_gif_creator(ic, parameters, quiet = FALSE, ...)
ic |
An ee$ImageCollection. |
parameters |
List of parameters for visualization and animation. See details. |
quiet |
Logical. Suppress info message. |
... |
parameter(s) passed on to download.file |
The parameters argument is identical to visParams (See rgee::Map$addLayer
),
plus, optionally:
dimensions: A number or pair of numbers in format c(WIDTH,HEIGHT). Max dimensions of the thumbnail to render, in pixels. If only one number is passed, it is used as the maximum, and the other dimension is computed by proportional scaling.
crs: A CRS string specifying the projection of the output.
crs_transform: The affine transform to use for the output pixel grid.
scale: A scale to determine the output pixel grid; ignored if both crs and crs_transform are specified.
region: ee$Geometry$Polygon, GeoJSON or c(E,S,W,N). Geospatial region of the result. By default, the whole image.
format: String. The output format (only 'gif' is currently supported).
framesPerSecond: String. Animation speed.
A magick-image object of the specified ImageCollection.
Jeroen Ooms
Other GIF functions:
ee_utils_gif_annotate()
,
ee_utils_gif_save()
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() col <- ee$ImageCollection("JRC/GSW1_1/YearlyHistory")$map(function(img) { year <- img$date()$get("year") yearImg <- img$gte(2)$multiply(year) despeckle <- yearImg$connectedPixelCount(15, TRUE)$eq(15) yearImg$updateMask(despeckle)$selfMask()$set("year", year) }) appendReverse <- function(col) col$merge(col$sort('year', FALSE)) # ----------------------------------- # 1 Basic Animation - Ucayali Peru # ----------------------------------- bgColor = "FFFFFF" # Assign white to background pixels. riverColor = "0D0887" # Assign blue to river pixels. ## 1.1 Create the dataset annualCol = col$map(function(img) { img$unmask(0)$ visualize(min = 0, max = 1, palette = c(bgColor, riverColor))$ set("year", img$get("year")) }) basicAnimation <- appendReverse(annualCol) ## 1.2 Set video arguments aoi <- ee$Geometry$Rectangle(-74.327, -10.087, -73.931, -9.327) videoArgs = list( dimensions = 600, # Max dimension (pixels), min dimension is proportionally scaled. region = aoi, framesPerSecond = 10 ) ## 1.2 Download, display and save the GIF! animation <- ee_utils_gif_creator(basicAnimation, videoArgs, mode = "wb") get_years <- basicAnimation$aggregate_array("year")$getInfo() animation %>% ee_utils_gif_annotate("Ucayali, Peru") %>% ee_utils_gif_annotate(get_years, size = 15, location = "+90+40", boxcolor = "#FFFFFF") %>% ee_utils_gif_annotate("created using {magick} + {rgee}", size = 15, font = "sans",location = "+70+20") -> animation_wtxt gc(reset = TRUE) ee_utils_gif_save(animation_wtxt, path = paste0(tempfile(), ".gif")) ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() col <- ee$ImageCollection("JRC/GSW1_1/YearlyHistory")$map(function(img) { year <- img$date()$get("year") yearImg <- img$gte(2)$multiply(year) despeckle <- yearImg$connectedPixelCount(15, TRUE)$eq(15) yearImg$updateMask(despeckle)$selfMask()$set("year", year) }) appendReverse <- function(col) col$merge(col$sort('year', FALSE)) # ----------------------------------- # 1 Basic Animation - Ucayali Peru # ----------------------------------- bgColor = "FFFFFF" # Assign white to background pixels. riverColor = "0D0887" # Assign blue to river pixels. ## 1.1 Create the dataset annualCol = col$map(function(img) { img$unmask(0)$ visualize(min = 0, max = 1, palette = c(bgColor, riverColor))$ set("year", img$get("year")) }) basicAnimation <- appendReverse(annualCol) ## 1.2 Set video arguments aoi <- ee$Geometry$Rectangle(-74.327, -10.087, -73.931, -9.327) videoArgs = list( dimensions = 600, # Max dimension (pixels), min dimension is proportionally scaled. region = aoi, framesPerSecond = 10 ) ## 1.2 Download, display and save the GIF! animation <- ee_utils_gif_creator(basicAnimation, videoArgs, mode = "wb") get_years <- basicAnimation$aggregate_array("year")$getInfo() animation %>% ee_utils_gif_annotate("Ucayali, Peru") %>% ee_utils_gif_annotate(get_years, size = 15, location = "+90+40", boxcolor = "#FFFFFF") %>% ee_utils_gif_annotate("created using {magick} + {rgee}", size = 15, font = "sans",location = "+70+20") -> animation_wtxt gc(reset = TRUE) ee_utils_gif_save(animation_wtxt, path = paste0(tempfile(), ".gif")) ## End(Not run)
Write a magick-image object as a GIF file using the magick
package. This
function is a wrapper around image_write.
ee_utils_gif_save( image, path = NULL, format = NULL, quality = NULL, depth = NULL, density = NULL, comment = NULL, flatten = FALSE )
ee_utils_gif_save( image, path = NULL, format = NULL, quality = NULL, depth = NULL, density = NULL, comment = NULL, flatten = FALSE )
image |
magick image object returned by image_read. |
path |
path a file, url, or raster object or bitmap array. |
format |
output format such as |
quality |
number between 0 and 100 for jpeg quality. Defaults to 75. |
depth |
color depth (either 8 or 16). |
density |
resolution to render pdf or svg. |
comment |
text string added to the image metadata for supported formats. |
flatten |
should the image be flattened before writing? This also replaces transparency with a background color. |
No return value, called to write a GIF file.
Jeroen Ooms
Other GIF functions:
ee_utils_gif_annotate()
,
ee_utils_gif_creator()
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() col <- ee$ImageCollection("JRC/GSW1_1/YearlyHistory")$map(function(img) { year <- img$date()$get("year") yearImg <- img$gte(2)$multiply(year) despeckle <- yearImg$connectedPixelCount(15, TRUE)$eq(15) yearImg$updateMask(despeckle)$selfMask()$set("year", year) }) appendReverse <- function(col) col$merge(col$sort('year', FALSE)) # ----------------------------------- # 1 Basic Animation - Ucayali Peru # ----------------------------------- bgColor = "FFFFFF" # Assign white to background pixels. riverColor = "0D0887" # Assign blue to river pixels. ## 1.1 Create the dataset annualCol = col$map(function(img) { img$unmask(0)$ visualize(min = 0, max = 1, palette = c(bgColor, riverColor))$ set("year", img$get("year")) }) basicAnimation <- appendReverse(annualCol) ## 1.2 Set video arguments aoi <- ee$Geometry$Rectangle(-74.327, -10.087, -73.931, -9.327) videoArgs = list( dimensions = 600, # Max dimension (pixels), min dimension is proportionally scaled. region = aoi, framesPerSecond = 10 ) ## 1.2 Download, display and save the GIF! animation <- ee_utils_gif_creator(basicAnimation, videoArgs, mode = "wb") get_years <- basicAnimation$aggregate_array("year")$getInfo() animation %>% ee_utils_gif_annotate("Ucayali, Peru") %>% ee_utils_gif_annotate(get_years, size = 15, location = "+90+40", boxcolor = "#FFFFFF") %>% ee_utils_gif_annotate("created using {magick} + {rgee}", size = 15, font = "sans",location = "+70+20") -> animation_wtxt gc(reset = TRUE) ee_utils_gif_save(animation_wtxt, path = paste0(tempfile(), ".gif")) ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() col <- ee$ImageCollection("JRC/GSW1_1/YearlyHistory")$map(function(img) { year <- img$date()$get("year") yearImg <- img$gte(2)$multiply(year) despeckle <- yearImg$connectedPixelCount(15, TRUE)$eq(15) yearImg$updateMask(despeckle)$selfMask()$set("year", year) }) appendReverse <- function(col) col$merge(col$sort('year', FALSE)) # ----------------------------------- # 1 Basic Animation - Ucayali Peru # ----------------------------------- bgColor = "FFFFFF" # Assign white to background pixels. riverColor = "0D0887" # Assign blue to river pixels. ## 1.1 Create the dataset annualCol = col$map(function(img) { img$unmask(0)$ visualize(min = 0, max = 1, palette = c(bgColor, riverColor))$ set("year", img$get("year")) }) basicAnimation <- appendReverse(annualCol) ## 1.2 Set video arguments aoi <- ee$Geometry$Rectangle(-74.327, -10.087, -73.931, -9.327) videoArgs = list( dimensions = 600, # Max dimension (pixels), min dimension is proportionally scaled. region = aoi, framesPerSecond = 10 ) ## 1.2 Download, display and save the GIF! animation <- ee_utils_gif_creator(basicAnimation, videoArgs, mode = "wb") get_years <- basicAnimation$aggregate_array("year")$getInfo() animation %>% ee_utils_gif_annotate("Ucayali, Peru") %>% ee_utils_gif_annotate(get_years, size = 15, location = "+90+40", boxcolor = "#FFFFFF") %>% ee_utils_gif_annotate("created using {magick} + {rgee}", size = 15, font = "sans",location = "+70+20") -> animation_wtxt gc(reset = TRUE) ee_utils_gif_save(animation_wtxt, path = paste0(tempfile(), ".gif")) ## End(Not run)
If it exists, retrieve the citation of an EE object.
`ee$Image$Extra_getCitation(x)` `ee$ImageCollection$Extra_getCitation(x)`
`ee$Image$Extra_getCitation(x)` `ee$ImageCollection$Extra_getCitation(x)`
x |
An EE object to get the citation from. |
A character with citation information.
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() # Retrieve citation for the first image in NASA's IMERG V06 collection citation <- ee$ImageCollection("NASA/GPM_L3/IMERG_V06")[[1]] %>% ee$Image$Extra_getCitation() # Display the citation citation # Fetching NASA/GPM_L3/IMERG_V06 image collection and retrieving its citation. citation_ <- ee$ImageCollection("NASA/GPM_L3/IMERG_V06") %>% ee$ImageCollection$Extra_getCitation() # Display the citation citation_ ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() # Retrieve citation for the first image in NASA's IMERG V06 collection citation <- ee$ImageCollection("NASA/GPM_L3/IMERG_V06")[[1]] %>% ee$Image$Extra_getCitation() # Display the citation citation # Fetching NASA/GPM_L3/IMERG_V06 image collection and retrieving its citation. citation_ <- ee$ImageCollection("NASA/GPM_L3/IMERG_V06") %>% ee$ImageCollection$Extra_getCitation() # Display the citation citation_ ## End(Not run)
If it exists, retrieve the DOI of an EE object.
`ee$Image$Extra_getDOI(x)` `ee$ImageCollection$Extra_getDOI(x)`
`ee$Image$Extra_getDOI(x)` `ee$ImageCollection$Extra_getDOI(x)`
x |
An EE object to get the DOI from. |
A character with DOI information.
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() # Fetch DOI for first image in NASA IMERG V06 collection doi <- ee$ImageCollection("NASA/GPM_L3/IMERG_V06")[[1]] %>% ee$Image$Extra_getDOI() doi # Retrieve and print the DOI for the NASA/GPM_L3/IMERG_V06 image collection. doi_ <- ee$ImageCollection("NASA/GPM_L3/IMERG_V06") %>% ee$ImageCollection$Extra_getDOI() doi_ ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() # Fetch DOI for first image in NASA IMERG V06 collection doi <- ee$ImageCollection("NASA/GPM_L3/IMERG_V06")[[1]] %>% ee$Image$Extra_getDOI() doi # Retrieve and print the DOI for the NASA/GPM_L3/IMERG_V06 image collection. doi_ <- ee$ImageCollection("NASA/GPM_L3/IMERG_V06") %>% ee$ImageCollection$Extra_getDOI() doi_ ## End(Not run)
Earth Engine apply a simply lossless compression technique: IMG_Float_Values = scale * IMG_Integer_Values + offset. ee$Image$getOffsetParams or ee$ImageCollection$getOffsetParams retrieve the offset parameter for each band of an ee$Image.
`ee$Image$Extra_getOffsetParams(x)` `ee$ImageCollection$Extra_getOffsetParams(x)`
`ee$Image$Extra_getOffsetParams(x)` `ee$ImageCollection$Extra_getOffsetParams(x)`
x |
An ee$Image or an ee$ImageCollection object. |
A list with the offset parameters for each band.
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() # Retrieve offset parameters from the first image in NASA IMERG V06 collection offset_params <- ee$ImageCollection("NASA/GPM_L3/IMERG_V06")[[1]] %>% ee$Image$Extra_getOffsetParams() # Display offset parameters for each band. offset_params # Get offset parameters from NASA IMERG V06 image collection. offset_params_ <- ee$ImageCollection("NASA/GPM_L3/IMERG_V06") %>% ee$ImageCollection$Extra_getOffsetParams() # Display offset parameters for each band. offset_params_ ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() # Retrieve offset parameters from the first image in NASA IMERG V06 collection offset_params <- ee$ImageCollection("NASA/GPM_L3/IMERG_V06")[[1]] %>% ee$Image$Extra_getOffsetParams() # Display offset parameters for each band. offset_params # Get offset parameters from NASA IMERG V06 image collection. offset_params_ <- ee$ImageCollection("NASA/GPM_L3/IMERG_V06") %>% ee$ImageCollection$Extra_getOffsetParams() # Display offset parameters for each band. offset_params_ ## End(Not run)
Earth Engine apply a simply lossless compression technique: IMG_Float_Values = scale * IMG_Integer_Values + offset. ee$Image$getScaleParams and ee$ImageCollection$getScaleParams retrieve the scale parameter for each band of an ee$Image.
`ee$Image$Extra_getScaleParams(x)` `ee$ImageCollection$Extra_getScaleParams(x)`
`ee$Image$Extra_getScaleParams(x)` `ee$ImageCollection$Extra_getScaleParams(x)`
x |
An ee$Image.or an ee$ImageCollection object. |
A list with the scale parameters for each band.
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() # Retrieve scale parameters from the first image in NASA IMERG V06 collection scale_params <- ee$ImageCollection("NASA/GPM_L3/IMERG_V06")[[1]] %>% ee$Image$Extra_getScaleParams() # Display scale parameters for each band in the image. scale_params # Retrieve scale parameters for the NASA IMERG V06 collection. scale_params_ <- ee$ImageCollection("NASA/GPM_L3/IMERG_V06") %>% ee$Image$Extra_getScaleParams() # Display scale parameters for each band in the image. scale_params_ ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() # Retrieve scale parameters from the first image in NASA IMERG V06 collection scale_params <- ee$ImageCollection("NASA/GPM_L3/IMERG_V06")[[1]] %>% ee$Image$Extra_getScaleParams() # Display scale parameters for each band in the image. scale_params # Retrieve scale parameters for the NASA IMERG V06 collection. scale_params_ <- ee$ImageCollection("NASA/GPM_L3/IMERG_V06") %>% ee$Image$Extra_getScaleParams() # Display scale parameters for each band in the image. scale_params_ ## End(Not run)
Get the STAC of an ee$Image or ee$ImageCollection object.
`ee$Image$Extra_getSTAC(x)` `ee$ImageCollection$Extra_getSTAC(x)`
`ee$Image$Extra_getSTAC(x)` `ee$ImageCollection$Extra_getSTAC(x)`
x |
An ee$Image or an ee$ImageCollection object. |
Return STAC metadata for each band.
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() # Retrieve STAC metadata for the first image in NASA's GPM L3 IMERG V06 collection stac_metadata <- ee$ImageCollection("NASA/GPM_L3/IMERG_V06")[[1]] %>% ee$Image$Extra_getSTAC() stac_metadata # Retrieve STAC metadata from NASA's IMERG V06 image collection. stac_metadata_ <- ee$ImageCollection("NASA/GPM_L3/IMERG_V06") %>% ee$ImageCollection$Extra_getSTAC() stac_metadata_ ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() # Retrieve STAC metadata for the first image in NASA's GPM L3 IMERG V06 collection stac_metadata <- ee$ImageCollection("NASA/GPM_L3/IMERG_V06")[[1]] %>% ee$Image$Extra_getSTAC() stac_metadata # Retrieve STAC metadata from NASA's IMERG V06 image collection. stac_metadata_ <- ee$ImageCollection("NASA/GPM_L3/IMERG_V06") %>% ee$ImageCollection$Extra_getSTAC() stac_metadata_ ## End(Not run)
Apply panchromatic sharpening to an ee$Image. Optionally, run quality assessments between the original and sharpened Image to measure spectral distortion and set results as properties of the sharpened Image.
`ee$Image$Extra_panSharpen(x, ...)`
`ee$Image$Extra_panSharpen(x, ...)`
x |
An ee$Image object, the image to sharpen. |
... |
Additional arguments including sharpening method, quality
assessments, and parameters for |
The ...
argument can include the following:
methodCharacter. The sharpening algorithm to apply. Options include “SFIM”, “HPFA”, “PCS”, and “SM”. Default is “SFIM”.
qaCharacter. One or more quality assessment names to apply after sharpening, such as “MSE”, “RASE”, “UIQI”, etc.
geometry, maxPixels, bestEffort, etc.Arguments passed to ee.Image.reduceRegion()
during PCS sharpening and quality assessments.
For the PCS method, additional parameters for ee.Image.reduceRegion()
can be specified,
such as geometry
, maxPixels
, bestEffort
, etc.
The Image with all sharpenable bands sharpened to the panchromatic resolution and quality assessments run and set as properties.
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() img <- ee$Image("LANDSAT/LC09/C02/T1_TOA/LC09_047027_20230815") img_sharp <- ee$Image$Extra_panSharpen(img, method="HPFA", qa=c("MSE", "RMSE"), maxPixels=1e13) Map$centerObject(img) Map$addLayer(img_sharp, list(bands=c("B4", "B3", "B2"))) | Map$addLayer(img, list(bands=c("B4", "B3", "B2"))) ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() img <- ee$Image("LANDSAT/LC09/C02/T1_TOA/LC09_047027_20230815") img_sharp <- ee$Image$Extra_panSharpen(img, method="HPFA", qa=c("MSE", "RMSE"), maxPixels=1e13) Map$centerObject(img) Map$addLayer(img_sharp, list(bands=c("B4", "B3", "B2"))) | Map$addLayer(img, list(bands=c("B4", "B3", "B2"))) ## End(Not run)
Preprocessing of ee$Image or ee$ImageCollection objects. This function performs the following tasks:
Cloud Masking: Remove cloud and cloud shadow pixels. See ee$Image$cloudmask.
Decompress: Convert integer pixels to float point numbers.
`ee$Image$Extra_preprocess(x, ...)` `ee$ImageCollection$Extra_preprocess(x, ...)`
`ee$Image$Extra_preprocess(x, ...)` `ee$ImageCollection$Extra_preprocess(x, ...)`
x |
An ee$Image or an ee$ImageCollection object. |
... |
Arguments to pass to ee$Image$cloudmask. |
An ee$Image or ee$ImageCollection object
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() # Load a Sentinel-2 image and apply automated preprocessing. img <- ee$Image("COPERNICUS/S2_SR/20170328T083601_20170328T084228_T35SQA") %>% ee$Image$Extra_preprocess() # Load and preprocess Sentinel-2 SR image collection. ic <- ee$ImageCollection$Dataset$COPERNICUS_S2_SR %>% ee$ImageCollection$Extra_preprocess() ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() # Load a Sentinel-2 image and apply automated preprocessing. img <- ee$Image("COPERNICUS/S2_SR/20170328T083601_20170328T084228_T35SQA") %>% ee$Image$Extra_preprocess() # Load and preprocess Sentinel-2 SR image collection. ic <- ee$ImageCollection$Dataset$COPERNICUS_S2_SR %>% ee$ImageCollection$Extra_preprocess() ## End(Not run)
Earth Engine apply a simply lossless compression technique: IMG_Float_Values = scale * IMG_Integer_Values + offset. ee$Image$scaleAndOffset or ee$ImageCollection$scaleAndOffset backs the integer pixel values to float point number.
`ee$Image$Extra_scaleAndOffset(x)` `ee$ImageCollection$Extra_scaleAndOffset(x)`
`ee$Image$Extra_scaleAndOffset(x)` `ee$ImageCollection$Extra_scaleAndOffset(x)`
x |
An ee$Image or an ee$ImageCollection object. |
An ee$Image or an ee$ImageCollection with float pixel values.
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() # Adjust first image in NASA IMERG V06 for scale and offset. adjusted_image <- ee$ImageCollection("NASA/GPM_L3/IMERG_V06")[[1]] %>% ee$Image$Extra_scaleAndOffset() # Adjust Sentinel-2 SR images for scale and offset. adjusted_images <- ee$ImageCollection("COPERNICUS/S2_SR") %>% ee$ImageCollection$Extra_scaleAndOffset() ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() # Adjust first image in NASA IMERG V06 for scale and offset. adjusted_image <- ee$ImageCollection("NASA/GPM_L3/IMERG_V06")[[1]] %>% ee$Image$Extra_scaleAndOffset() # Adjust Sentinel-2 SR images for scale and offset. adjusted_images <- ee$ImageCollection("COPERNICUS/S2_SR") %>% ee$ImageCollection$Extra_scaleAndOffset() ## End(Not run)
Extract or replace parts of ee$Image and ee$ImageCollection
Extract or replace parts of and ee$ImageCollection
## S3 method for class 'ee.image.Image' x[[index]] ## S3 replacement method for class 'ee.image.Image' x[index] <- value ## S3 replacement method for class 'ee.image.Image' x[[index]] <- value ## S3 method for class 'ee.imagecollection.ImageCollection' x[[index]] ## S3 replacement method for class 'ee.imagecollection.ImageCollection' x[[index]] <- value
## S3 method for class 'ee.image.Image' x[[index]] ## S3 replacement method for class 'ee.image.Image' x[index] <- value ## S3 replacement method for class 'ee.image.Image' x[[index]] <- value ## S3 method for class 'ee.imagecollection.ImageCollection' x[[index]] ## S3 replacement method for class 'ee.imagecollection.ImageCollection' x[[index]] <- value
x |
ee$ImageCollection or ee$Image. |
index |
Integer. Index specifying elements to extract or replace. |
value |
ee$ImageCollection or ee$Image to replace in. |
Bands of ee$Image or an ee$Image
An EE.ImageCollection
## Not run: library(rgee) library(rgeeExtra) library(sf) ee_Initialize(gcs = TRUE, drive = TRUE) # Define a Image or ImageCollection: Terraclimate terraclimate <- ee$ImageCollection("IDAHO_EPSCOR/TERRACLIMATE") %>% ee$ImageCollection$filterDate("2001-01-01", "2002-01-01") # Define temperature Vis parameters maximumTemperatureVis <- list( min = -300.0, max = 300.0, palette = c( '1a3678', '2955bc', '5699ff', '8dbae9', 'acd1ff', 'caebff', 'e5f9ff', 'fdffb4', 'ffe6a2', 'ffc969', 'ffa12d', 'ff7c1f', 'ca531a', 'ff0000', 'ab0000' ) ) Map$setCenter(71.72, 52.48, 2) tnames <- names(terraclimate[[2]]) m1 <- Map$addLayer(terraclimate[[2]][["tmmx"]], maximumTemperatureVis) terraclimate[[2]] <- terraclimate[[2]]*1.4 names(terraclimate[[2]]) <- tnames m2 <- Map$addLayer(terraclimate[[2]][["tmmx"]], maximumTemperatureVis) m1 | m2 ## End(Not run) ## Not run: library(rgee) library(rgeeExtra) library(sf) ee_Initialize(gcs = TRUE, drive = TRUE) extra_Initialize() # Define a Image or ImageCollection: Terraclimate ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) library(sf) ee_Initialize(gcs = TRUE, drive = TRUE) # Define a Image or ImageCollection: Terraclimate terraclimate <- ee$ImageCollection("IDAHO_EPSCOR/TERRACLIMATE") %>% ee$ImageCollection$filterDate("2001-01-01", "2002-01-01") # Define temperature Vis parameters maximumTemperatureVis <- list( min = -300.0, max = 300.0, palette = c( '1a3678', '2955bc', '5699ff', '8dbae9', 'acd1ff', 'caebff', 'e5f9ff', 'fdffb4', 'ffe6a2', 'ffc969', 'ffa12d', 'ff7c1f', 'ca531a', 'ff0000', 'ab0000' ) ) Map$setCenter(71.72, 52.48, 2) tnames <- names(terraclimate[[2]]) m1 <- Map$addLayer(terraclimate[[2]][["tmmx"]], maximumTemperatureVis) terraclimate[[2]] <- terraclimate[[2]]*1.4 names(terraclimate[[2]]) <- tnames m2 <- Map$addLayer(terraclimate[[2]][["tmmx"]], maximumTemperatureVis) m1 | m2 ## End(Not run) ## Not run: library(rgee) library(rgeeExtra) library(sf) ee_Initialize(gcs = TRUE, drive = TRUE) extra_Initialize() # Define a Image or ImageCollection: Terraclimate ## End(Not run)
Tasseled cap transformations are applied using coefficients published for these supported platforms:
1. Sentinel-2 MSI Level 1C (1)
2. Landsat 9 OLI-2 SR (2)
3. Landsat 9 OLI-2 TOA (2)
4. Landsat 8 OLI SR (2)
5. Landsat 8 OLI TOA (2)
6. Landsat 7 ETM+ TOA (3)
7. Landsat 5 TM Raw DN (4)
8. Landsat 4 TM Raw DN (5)
9. Landsat 4 TM Surface Reflectance (6)
10. MODIS NBAR (7)
`ee$Image$Extra_tasseledCap(x)`
`ee$Image$Extra_tasseledCap(x)`
x |
ee$Image to calculate tasseled cap components for. Must belong to a supported platform. |
1. Shi, T., & Xu, H. (2019). Derivation of Tasseled Cap Transformation Coefficients for Sentinel-2 MSI At-Sensor Reflectance Data. IEEE Journal of Selected Topics in Applied Earth Observations and Remote Sensing, 1–11. doi:10.1109/jstars.2019.2938388
2. Zhai, Y., Roy, D.P., Martins, V.S., Zhang, H.K., Yan, L., Li, Z. 2022. Conterminous United States Landsat-8 top of atmosphere and surface reflectance tasseled cap transformation coefficeints. Remote Sensing of Environment, 274(2022). doi:10.1016/j.rse.2022.112992
3. Huang, C., Wylie, B., Yang, L., Homer, C. and Zylstra, G., 2002. Derivation of a tasselled cap transformation based on Landsat 7 at-satellite reflectance. International journal of remote sensing, 23(8), pp.1741-1748.
4. Crist, E.P., Laurin, R. and Cicone, R.C., 1986, September. Vegetation and soils information contained in transformed Thematic Mapper data. In Proceedings of IGARSS’86 symposium (pp. 1465-1470). Paris: European Space Agency Publications Division.
5. Crist, E.P. and Cicone, R.C., 1984. A physically-based transformation of Thematic Mapper data—The TM Tasseled Cap. IEEE Transactions on Geoscience and Remote sensing, (3), pp.256-263.
6. Crist, E.P., 1985. A TM tasseled cap equivalent transformation for reflectance factor data. Remote sensing of Environment, 17(3), pp.301-306.
7. Lobser, S.E. and Cohen, W.B., 2007. MODIS tasselled cap: land cover characteristics expressed through transformed MODIS data. International Journal of Remote Sensing, 28(22), pp.5079-5101.
ee$Image with the tasseled cap components as new bands.
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() img <- ee$Image("LANDSAT/LT05/C01/T1/LT05_044034_20081011") img <- ee$Image$Extra_tasseledCap(img) names(img) ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() img <- ee$Image("LANDSAT/LT05/C01/T1/LT05_044034_20081011") img <- ee$Image$Extra_tasseledCap(img) names(img) ## End(Not run)
Load extra functionality for rgee
extra_Initialize(quiet = FALSE)
extra_Initialize(quiet = FALSE)
quiet |
Logical. Suppress info messages. |
TRUE if the function runs smoothly.
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() # Initialize GEE extra_Initialize() # Extent the GEE API ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() # Initialize GEE extra_Initialize() # Extent the GEE API ## End(Not run)
Returns the minimum or maximum value of an ee.Image. The return value will be an approximation if the polygon (area of the ee.Image) contains too many pixels at the native scale.
`ee$Image$Extra_maxValue(x, ...)` `ee$Image$Extra_minValue(x, ...)`
`ee$Image$Extra_maxValue(x, ...)` `ee$Image$Extra_minValue(x, ...)`
x |
ee$Image to analyze. |
... |
Additional arguments for specifying the mode and sampling. See details for more information. |
The ...
argument can include the following:
modeCharacter. Indicates the geometry over which to reduce data. Options: "Rectangle" (default) or "Points".
sample_sizeNumeric. Number of points to be created. Relevant only if mode is "Points".
The "Rectangle" mode uses the Image system:footprint, while the "Points" mode samples points over the Image system:footprint.
A number representing the minimum or maximum value.
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() image <- ee$ImageCollection$Dataset$LANDSAT_LC08_C01_T1$first()[["B1"]] # max values ee$Image$Extra_maxValue(image) ee$Image$Extra_maxValue(image, mode = "Points", sample_size = 2) # min values ee$Image$Extra_minValue(image) ee$Image$Extra_minValue(image, mode = "Points") ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() image <- ee$ImageCollection$Dataset$LANDSAT_LC08_C01_T1$first()[["B1"]] # max values ee$Image$Extra_maxValue(image) ee$Image$Extra_maxValue(image, mode = "Points", sample_size = 2) # min values ee$Image$Extra_minValue(image) ee$Image$Extra_minValue(image, mode = "Points") ## End(Not run)
Get or set the length of an Earth Engine Image.
## S3 method for class 'ee.image.Image' length(x)
## S3 method for class 'ee.image.Image' length(x)
x |
an EE Image Object. |
If a vector is shortened, extra values are discarded and when a vector is lengthened, it is padded out to its new length with ee$Image(0), with band name of zzz_rgee_NA_%02d.
A numeric value that indicate the number of bands in a ee$Image.
## Not run: library(rgeeExtra) library(rgee) ee_Initialize() # Initialize the Google Earth Engine API connection extra_Initialize() # Initialize the extended functionalities of rgeeExtra ic <- ee$Image("COPERNICUS/S2_SR/20190310T105851_20190310T110327_T30TVK") length(ic) ## End(Not run)
## Not run: library(rgeeExtra) library(rgee) ee_Initialize() # Initialize the Google Earth Engine API connection extra_Initialize() # Initialize the extended functionalities of rgeeExtra ic <- ee$Image("COPERNICUS/S2_SR/20190310T105851_20190310T110327_T30TVK") length(ic) ## End(Not run)
Mathematical functions
## S3 method for class 'ee.image.Image' Math(x, ...)
## S3 method for class 'ee.image.Image' Math(x, ...)
x |
ee$Image |
... |
Ignored Generic mathematical functions that can be used with an |
An ee$Image object
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() roi <- ee$Geometry$Point(c(-79, -12)) a <- ee$Image(1) b <- ee$Image(2) c <- a + b log1p(ee$Image(10)) ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() roi <- ee$Geometry$Point(c(-79, -12)) a <- ee$Image(1) b <- ee$Image(2) c <- a + b log1p(ee$Image(10)) ## End(Not run)
Get the names of the layers of an Earth Engine Image object.
`names(x)`
`names(x)`
x |
an EE Image object. |
A vector with the name of the bands.
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() img_demo <- ee$Image("COPERNICUS/S2_SR/20190310T105851_20190310T110327_T30TVK")[[1:3]] names(img_demo) ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() img_demo <- ee$Image("COPERNICUS/S2_SR/20190310T105851_20190310T110327_T30TVK")[[1:3]] names(img_demo) ## End(Not run)
Set the names of the layers of an Earth Engine Image object.
`names(x) <- value`
`names(x) <- value`
x |
an EE Image object. |
value |
a character vector with the same length as x. |
An ee$Image with its bands renamed.
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() img_demo <- ee$Image("COPERNICUS/S2_SR/20190310T105851_20190310T110327_T30TVK")[[1:3]] names(img_demo) <- c("B01", "B02", "B03") ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() extra_Initialize() img_demo <- ee$Image("COPERNICUS/S2_SR/20190310T105851_20190310T110327_T30TVK")[[1:3]] names(img_demo) <- c("B01", "B02", "B03") ## End(Not run)
Arithmetic, logic and compare operators for computation with ee$Image
objects and numeric values.
## S3 method for class 'ee.image.Image' Ops(e1, e2)
## S3 method for class 'ee.image.Image' Ops(e1, e2)
e1 |
Numeric or ee$Image. |
e2 |
Numeric or ee$Image. |
Arith: +, -, *, /, ^, %%, %/%, %>>% and %>>%.
Logic: !, &, |.
Comparison: ==, !=, >, <, <=, >=
An ee$Image object
## Not run: library(rgee) ee_Initialize() # Sum Operator ee1 <- ee$Image(1) ee2 <- ee$Image(2) ee3 <- ee1 + ee2 ee_extract(ee3, ee$Geometry$Point(0, 0)) v1 <- 1 v2 <- 2 v3 <- v1 + v2 v3 # Multiple Operators ee4 <- ee1 / 10 ee5 <- ee4 * (ee2 - 1 + ee1^2 / ee2) ee_extract(ee5, ee$Geometry$Point(0, 0)) v4 <- v1 / 10 v5 <- v4 * (v2 - 1 + v1^2 / v2) v5 # multi-layer object mutiplication, no recycling ee6 <- ee1 + c(1, 5, 10) ee_extract(ee6, ee$Geometry$Point(0, 0)) v6 <- v1 + c(1, 5, 10) v6 ## End(Not run)
## Not run: library(rgee) ee_Initialize() # Sum Operator ee1 <- ee$Image(1) ee2 <- ee$Image(2) ee3 <- ee1 + ee2 ee_extract(ee3, ee$Geometry$Point(0, 0)) v1 <- 1 v2 <- 2 v3 <- v1 + v2 v3 # Multiple Operators ee4 <- ee1 / 10 ee5 <- ee4 * (ee2 - 1 + ee1^2 / ee2) ee_extract(ee5, ee$Geometry$Point(0, 0)) v4 <- v1 / 10 v5 <- v4 * (v2 - 1 + v1^2 / v2) v5 # multi-layer object mutiplication, no recycling ee6 <- ee1 + c(1, 5, 10) ee_extract(ee6, ee$Geometry$Point(0, 0)) v6 <- v1 + c(1, 5, 10) v6 ## End(Not run)
Summary Methods
## S3 method for class 'ee.image.Image' Summary(..., na.rm = TRUE) ## S3 method for class 'ee.image.Image' mean(..., na.rm = TRUE)
## S3 method for class 'ee.image.Image' Summary(..., na.rm = TRUE) ## S3 method for class 'ee.image.Image' mean(..., na.rm = TRUE)
... |
ee$Image. |
na.rm |
Ignore. |
An ee$Image object
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() roi <- ee$Geometry$Point(c(-79, -12)) img_demo <- ee$Image("COPERNICUS/S2_SR/20190310T105851_20190310T110327_T30TVK") max(img_demo) ## End(Not run)
## Not run: library(rgee) library(rgeeExtra) ee_Initialize() roi <- ee$Geometry$Point(c(-79, -12)) img_demo <- ee$Image("COPERNICUS/S2_SR/20190310T105851_20190310T110327_T30TVK") max(img_demo) ## End(Not run)