rr: Reduce Regions

View source: R/reduceRegions.R

rrR Documentation

Reduce Regions

Description

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

Usage

rr(
  data,
  geeFC = NULL,
  scale,
  tileScale = 1,
  band = NULL,
  lazy = FALSE,
  variable = NULL,
  leaflet = FALSE,
  palette = hcl.colors(n = 11),
  user_geom = 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. ex hcl.colors('Zissou1', n = 11).

user_geom

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_geom 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

## Not run: 
# Load Libraries

library(rgee)
ee_Initialize()
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')


## End(Not run)

joshualerickson/exploreRGEE documentation built on May 9, 2022, 10:33 p.m.