This function allows the user to pass a previously created get_*() object to get reduceRegions() by using ee_as_sf function.

rr(
  data,
  geeFC = NULL,
  scale,
  tileScale = 1,
  band = NULL,
  lazy = FALSE,
  variable = NULL,
  leaflet = FALSE,
  palette = "RdBu",
  n_pal = 11,
  reverse = FALSE,
  user_shape = NULL
)

Arguments

data

A previously created get_* object or ee.image.Image

geeFC

A known GEE FeatureCollection or asset, e.g. "USGS/WBD/2017/HUC12"

scale

A numeric value indicating scale in meters

tileScale

numeric what to reduce regions by, 1 (default). Higher means slower but less memory, e.g. 5.

band

A character indicating what bands/type to use when you have more than one.

lazy

logical whether to run a 'sequential' future in the background or not.

variable

character indicating what to label features in leaflet map, optional. NULL (default)

leaflet

logical. TRUE/FALSE whether to view map. FALSE (default).

palette

character color palette using colorBrewer format, e.g. "RdBu" (default), "RdYlGn", etc.

n_pal

numeric indicating levels of colors in palette. 6 (default).

reverse

logical TRUE/FALSE whether to reverse palette or not, FALSE (default).

user_shape

A sf object to use as 'region' for an 'ee.image.Image'.

Value

A leaflet map (leaflet = TRUE) and always a sf object.

Note

If lazy is TRUE, the function will be run in the background. If the pixel size is big then please adjust tileScale to account for memory. This will not effect zonal stats (pixel size) but will just take longer. user_shape in this function is used when applying a non-get_*() function to rr(); this means you can provide a 'ee.image.Image' and a sf object to run rr().

Examples

if (FALSE) {
# Load Libraries

library(rgee)
rgee::ee_intialize()
library(exploreRGEE)

# Bring in data
huc <- exploreRGEE::huc

ld8 <- get_landsat(huc, method = 'ld8', startDate = '2014-01-01',
                  endDate = '2018-12-31', c.low = 6, c.high = 11)

# without leaflet save to object
ld8_rr <- ld8 %>% rr(scale = 30, band = 'NDVI')

# with leaflet as side-effect
ld8 %>% rr(scale = 30, band = 'NDVI', leaflet = TRUE, variable = 'name')

# or side-effect leaflet and get sf object.
ld8_ts <- ld8 %>% band(scale = 500, band = 'NDVI', leaflet = TRUE, variable = 'name')

}