# NOT RUN {
library(rgee)
library(sf)
ee_Initialize()
# 1. Handling geometry parameters
# Simple
ee_x <- st_read(system.file("shape/nc.shp", package = "sf")) %>%
sf_as_ee()
Map$centerObject(eeObject = ee_x)
Map$addLayer(ee_x)
# Create a right-inside polygon.
toy_poly <- matrix(data = c(-35,-10,-35,10,35,10,35,-10,-35,-10),
ncol = 2,
byrow = TRUE) %>%
list() %>%
st_polygon()
holePoly <- sf_as_ee(x = toy_poly, evenOdd = FALSE)
# Create an even-odd version of the polygon.
evenOddPoly <- sf_as_ee(toy_poly, evenOdd = TRUE)
# Create a point to test the insideness of the polygon.
pt <- ee$Geometry$Point(c(1.5, 1.5))
# Check insideness with a contains operator.
print(holePoly$contains(pt)$getInfo() %>% ee_utils_py_to_r())
print(evenOddPoly$contains(pt)$getInfo() %>% ee_utils_py_to_r())
# # 2. Upload small geometries to EE asset
# assetId <- sprintf("%s/%s", ee_get_assethome(), 'toy_poly')
# eex <- sf_as_ee(
# x = toy_poly,
# overwrite = TRUE,
# assetId = assetId,
# via = "getInfo_to_asset")
# # 3. Upload large geometries to EE asset
# ee_Initialize(gcs = TRUE)
# assetId <- sprintf("%s/%s", ee_get_assethome(), 'toy_poly_gcs')
# eex <- sf_as_ee(
# x = toy_poly,
# overwrite = TRUE,
# assetId = assetId,
# bucket = 'rgee_dev',
# monitoring = FALSE,
# via = 'gcs_to_asset'
# )
# ee_monitoring()
# }
Run the code above in your browser using DataLab