Learn R Programming

rgee (version 0.2.0)

sf_as_ee: Convert an sf object to EE object

Description

Convert an sf object to EE object

Usage

sf_as_ee(x, check_ring_dir)

# S3 method for character sf_as_ee(x, check_ring_dir = FALSE, ...)

# S3 method for sf sf_as_ee(x, check_ring_dir = FALSE)

# S3 method for sfc sf_as_ee(x, check_ring_dir = FALSE)

# S3 method for sfg sf_as_ee(x, check_ring_dir = FALSE)

Arguments

x

sf object to be converted into a EE object.

check_ring_dir

logical. See st_read and details.

...

st_read arguments might be included.

Details

The conversion from sf to EE is a two-step process. First, sf_as_ee transform sf objects into a GeoJSON format using geojson_json. Second, the GeoJSON generated will be encrusted in an HTTP request using the server-side objects (ee$Geometry$*). If the sf object is a large spatial object (>1Mb) it is likely to cause bottlenecks and plodding connections. See Client vs Server documentation for more details. For dealing with very large spatial objects, it is recommended to import it into the GEE asset. See ee_upload for creating uploaded pipelines.

Earth Engine is strict on polygon ring directions (outer ring counter-clockwise, and the inner one clockwise). If check_ring_dir is TRUE, it check every ring, and revert them if necessary, to counter clockwise for outer, and clockwise for inner (hole) ones. By default this is FALSE because it is an expensive operation.

Examples

Run this code
# NOT RUN {
library(rgee)
library(sf)

ee_reattach() # reattach ee as a reserved word
ee_Initialize()

# sf
x <- st_read(system.file("shape/nc.shp", package = "sf")) %>%
  st_transform(4326)
ee_x <- sf_as_ee(x, check_ring_dir = TRUE)
ee_map(ee_x)
# }

Run the code above in your browser using DataLab