Learn R Programming

rgee (version 0.2.0)

ee_as_sf: Convert an EE table in a sf object

Description

Convert an EE table in a sf object

Usage

ee_as_sf(x)

Arguments

x

EE table to be converted into a sf object.

Value

An sf class object, see Details.

Details

Export large spatial objects it preferable to create export pipelines by using ee$batch$Export$table$* and rgee::ee_download_* instead of using ee_as_sf. See Client vs Server documentation for details.

Examples

Run this code
# NOT RUN {
library(rgee)
ee_reattach() # reattach ee as a reserved word
ee_Initialize()
roi <- ee$Geometry$Polygon(list(
  c(-122.27577209472656, 37.891247253777074),
  c(-122.27577209472656, 37.86875557241152),
  c(-122.24040985107422, 37.86875557241152),
  c(-122.24040985107422, 37.891247253777074)
))

blocks <- ee$FeatureCollection("TIGER/2010/Blocks")
subset <- blocks$filterBounds(roi)$limit(10)
sf_subset <- ee_as_sf(subset)
cat('Object size in Mb:', as.numeric(object.size(sf_subset)/10^6))
plot(sf_subset)
# Define an arbitrary region in which to compute random points.
region <- ee$Geometry$Rectangle(-119.224, 34.669, -99.536, 50.064)
# Create 100 random points in the region.
ee_randomPoints <- ee$FeatureCollection$randomPoints(region,100)
sf_randomPoints <- ee_as_sf(ee_randomPoints)
plot(sf_randomPoints)
# }

Run the code above in your browser using DataLab