Description Details Value Public fields Methods Examples
Create interactive visualizations of spatial EE objects
(ee$Geometry, ee$Image, ee$Feature, and ee$FeatureCollection)
using leaflet
.
Map
use the Earth Engine method
getMapId to fetch and return an ID dictionary being used to create
layers in a leaflet
object. Users can specify visualization
parameters to Map$addLayer by using the visParams argument. Each Earth
Engine spatial object has a specific format. For
ee$Image
, the
parameters available are:
Parameter | Description | Type |
bands | Comma-delimited list of three band names to be mapped to RGB | list |
min | Value(s) to map to 0 | number or list of three numbers, one for each band |
max | Value(s) to map to 1 | number or list of three numbers, one for each band |
gain | Value(s) by which to multiply each pixel value | number or list of three numbers, one for each band |
bias | Value(s) to add to each Digital Number (DN) value | number or list of three numbers, one for each band |
gamma | Gamma correction factor(s) | number or list of three numbers, one for each band |
palette | List of CSS-style color strings (single-band images only) | comma-separated list of hex strings |
opacity | The opacity of the layer (0.0 is fully transparent and 1.0 is fully opaque) | number |
If you add an ee$Image
to Map$addLayer without any additional
parameters, by default it assigns the first three bands to red,
green, and blue bands, respectively. The default stretch is based on the
min-max range. On the other hand, the available parameters for
ee$Geometry
, ee$Feature
, and ee$FeatureCollection
are:
color: A hex string in the format RRGGBB specifying the color to use for drawing the features. By default #000000.
pointRadius: The radius of the point markers. By default 3.
strokeWidth: The width of lines and polygon borders. By default 3.
Object of class leaflet
and EarthEngineMap
, with the
following extra parameters: tokens, name, opacity, shown, min, max, palette,
position, and legend. Use the $ method to retrieve the data (e.g. m$rgee$min).
lon
The longitude of the center, in degrees.
lat
The latitude of the center, in degrees.
zoom
The zoom level, from 1 to 24.
save_maps
Should R6Map
save the previous maps?. If TRUE, Map
will work in a OOP style, otherwise will be functional programming style.
previous_map_left
Container of maps in the left side.
previous_map_right
Container of maps in the right side.
new()
Constructor of R6Map.
R6Map$new(lon = -76.942478, lat = -12.172116, zoom = 18, save_maps = TRUE)
lon
The longitude of the center, in degrees. By default -76.942478.
lat
The latitude of the center, in degrees. By default -12.172116.
zoom
The zoom level, from 1 to 24. By default 18.
save_maps
Should R6Map
save previous maps?.
A new EarthEngineMap
object.
reset()
Reset to initial arguments.
R6Map$reset(lon = -76.942478, lat = -12.172116, zoom = 18, save_maps = TRUE)
lon
The longitude of the center, in degrees. By default -76.942478.
lat
The latitude of the center, in degrees. By default -12.172116.
zoom
The zoom level, from 1 to 24. By default 18.
save_maps
Should R6Map
save previous maps?.
A new EarthEngineMap
object.
library(rgee) ee_Initialize() # Load an Image image <- ee$Image("LANDSAT/LC08/C01/T1/LC08_044034_20140318") # Create Map <- R6Map$new() Map$centerObject(image) # Simple display: Map just will Map$addLayer(image, list(min=0, max = 10000, bands = c("B4", "B3", "B2")), name = "l8_01") Map # display map Map$reset() # Reset arguments Map
print()
Display a EarthEngineMap
object.
R6Map$print()
An EarthEngineMap
object.
setCenter()
Centers the map view at the given coordinates with the given zoom level. If no zoom level is provided, it uses 10 by default.
R6Map$setCenter(lon = 0, lat = 0, zoom = 10)
lon
The longitude of the center, in degrees. By default -76.942478.
lat
The latitude of the center, in degrees. By default -12.172116.
zoom
The zoom level, from 1 to 24. By default 18.
No return value, called to set initial coordinates and zoom.
library(rgee) ee_Initialize() Map <- R6Map$new() Map$setCenter(lon = -76, lat = 0, zoom = 5) Map # Map$lat # Map$lon # Map$zoom
setZoom()
Sets the zoom level of the map.
R6Map$setZoom(zoom = 10)
zoom
The zoom level, from 1 to 24. By default 10.
No return value, called to set zoom.
library(rgee) ee_Initialize() Map <- R6Map$new() Map$setZoom(zoom = 4) Map # Map$lat # Map$lon # Map$zoom
centerObject()
Centers the map view on a given object. If no zoom level is provided, it will be predicted according to the bounds of the Earth Engine object specified.
R6Map$centerObject(eeObject, zoom = NULL, maxError = ee$ErrorMargin(1))
eeObject
Earth Engine spatial object.
zoom
The zoom level, from 1 to 24. By default NULL.
maxError
Max error when input image must be reprojected to an explicitly requested result projection or geodesic state.
No return value, called to set zoom.
library(rgee) ee_Initialize() Map <- R6Map$new() image <- ee$Image("LANDSAT/LC08/C01/T1/LC08_044034_20140318") Map$centerObject(image) Map
addLayer()
Adds a given Eath Engine spatial object to the map as a layer
R6Map$addLayer( eeObject, visParams = NULL, name = NULL, shown = TRUE, opacity = 1, position = NULL, legend = FALSE )
eeObject
The Earth Engine spatial object to display in the interactive map.
visParams
List of parameters for visualization. See details.
name
The name of layers.
shown
A flag indicating whether layers should be on by default.
opacity
The layer's opacity represented as a number between 0 and 1. Defaults to 1.
position
Character. Activate panel creation. If "left" the map will be displayed in the left panel. Otherwise, if it is "right" the map will be displayed in the right panel. By default NULL (No panel will be created).
legend
Should a legend be plotted?. Only the legend of the first image is displayed.
An EarthEngineMap
object.
library(rgee) ee_Initialize() # Load an Image image <- ee$Image("LANDSAT/LC08/C01/T1/LC08_044034_20140318") # Create Map <- R6Map$new() Map$centerObject(image) # Simple display: Map just will Map$addLayer(image, list(min=0, max = 10000, bands = c("B4", "B3", "B2")), name = "l8_01") Map$addLayer(image, list(min=0, max = 20000, bands = c("B4", "B3", "B2")), name = "l8_02") # Simple display: Map just will (if the position is not specified it will # be saved on the right side) Map$reset() # Reset Map to the initial arguments. Map$centerObject(image) Map$addLayer(image, list(min=0, max=10000, bands = c("B4", "B3", "B2")), name = "l8_left", position = "left") Map$addLayer(image, list(min=0, max=20000, bands = c("B4", "B3", "B2")), name = "l8_right")
addLayers()
Adds a given ee$ImageCollection to the map as multiple layers.
R6Map$addLayers( eeObject, visParams = NULL, nmax = 5, name = NULL, shown = TRUE, position = NULL, opacity = 1, legend = FALSE )
eeObject
ee$ImageCollection to display in the interactive map.
visParams
List of parameters for visualization. See details.
nmax
Numeric. The maximum number of images to display. By default 5.
name
The name of layers.
shown
A flag indicating whether layers should be on by default.
position
Character. Activate panel creation. If "left" the map will be displayed in the left panel. Otherwise, if it is "right" the map will be displayed in the right panel. By default NULL (No panel will be created).
opacity
The layer's opacity represented as a number between 0 and 1. Defaults to 1.
legend
Should a legend be plotted?. Only the legend of the first image is displayed.
A EarthEngineMap
object.
library(sf) library(rgee) ee_Initialize() Map <- R6Map$new() 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_get(0:2) Map$centerObject(nc$geometry()) Map$addLayers(eeObject = ee_s2, legend = TRUE, position = "right") Map$reset() # digging up the metadata Map$previous_map_right$rgee$tokens
clone()
The objects of this class are cloneable with this method.
R6Map$clone(deep = FALSE)
deep
Whether to make a deep clone.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | ## ------------------------------------------------
## Method `R6Map$reset`
## ------------------------------------------------
library(rgee)
ee_Initialize()
# Load an Image
image <- ee$Image("LANDSAT/LC08/C01/T1/LC08_044034_20140318")
# Create
Map <- R6Map$new()
Map$centerObject(image)
# Simple display: Map just will
Map$addLayer(image, list(min=0, max = 10000, bands = c("B4", "B3", "B2")), name = "l8_01")
Map # display map
Map$reset() # Reset arguments
Map
## ------------------------------------------------
## Method `R6Map$setCenter`
## ------------------------------------------------
library(rgee)
ee_Initialize()
Map <- R6Map$new()
Map$setCenter(lon = -76, lat = 0, zoom = 5)
Map
# Map$lat
# Map$lon
# Map$zoom
## ------------------------------------------------
## Method `R6Map$setZoom`
## ------------------------------------------------
library(rgee)
ee_Initialize()
Map <- R6Map$new()
Map$setZoom(zoom = 4)
Map
# Map$lat
# Map$lon
# Map$zoom
## ------------------------------------------------
## Method `R6Map$centerObject`
## ------------------------------------------------
library(rgee)
ee_Initialize()
Map <- R6Map$new()
image <- ee$Image("LANDSAT/LC08/C01/T1/LC08_044034_20140318")
Map$centerObject(image)
Map
## ------------------------------------------------
## Method `R6Map$addLayer`
## ------------------------------------------------
library(rgee)
ee_Initialize()
# Load an Image
image <- ee$Image("LANDSAT/LC08/C01/T1/LC08_044034_20140318")
# Create
Map <- R6Map$new()
Map$centerObject(image)
# Simple display: Map just will
Map$addLayer(image, list(min=0, max = 10000, bands = c("B4", "B3", "B2")), name = "l8_01")
Map$addLayer(image, list(min=0, max = 20000, bands = c("B4", "B3", "B2")), name = "l8_02")
# Simple display: Map just will (if the position is not specified it will
# be saved on the right side)
Map$reset() # Reset Map to the initial arguments.
Map$centerObject(image)
Map$addLayer(image, list(min=0, max=10000, bands = c("B4", "B3", "B2")), name = "l8_left", position = "left")
Map$addLayer(image, list(min=0, max=20000, bands = c("B4", "B3", "B2")), name = "l8_right")
## ------------------------------------------------
## Method `R6Map$addLayers`
## ------------------------------------------------
library(sf)
library(rgee)
ee_Initialize()
Map <- R6Map$new()
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_get(0:2)
Map$centerObject(nc$geometry())
Map$addLayers(eeObject = ee_s2, legend = TRUE, position = "right")
Map$reset()
# digging up the metadata
Map$previous_map_right$rgee$tokens
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.