ee_as_stars: Convert an Earth Engine (EE) image in a stars object

Description Usage Arguments Details Value See Also Examples

View source: R/ee_image.R

Description

Convert an ee$Image in a stars object.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
ee_as_stars(
  image,
  region = NULL,
  dsn = NULL,
  via = "drive",
  container = "rgee_backup",
  scale = NULL,
  maxPixels = 1e+09,
  lazy = FALSE,
  public = TRUE,
  add_metadata = TRUE,
  timePrefix = TRUE,
  quiet = FALSE,
  ...
)

Arguments

image

ee$Image to be converted into a stars object.

region

EE Geometry (ee$Geometry$Polygon) which specify the region to export. CRS needs to be the same that the argument image, otherwise, it will be forced. If not specified, image bounds are taken.

dsn

Character. Output filename. If missing, a temporary file is created.

via

Character. Method to export the image. Two method are implemented: "drive", "gcs". See details.

container

Character. Name of the folder ('drive') or bucket ('gcs') to be exported into.

scale

Numeric. The resolution in meters per pixel. Defaults to the native resolution of the image.

maxPixels

Numeric. The maximum allowed number of pixels in the exported image. The task will fail if the exported region covers more pixels in the specified projection. Defaults to 100,000,000.

lazy

Logical. If TRUE, a future::sequential object is created to evaluate the task in the future. See details.

public

Logical. If TRUE, a public link to the image is created.

add_metadata

Add metadata to the stars_proxy object. See details.

timePrefix

Logical. Add current date and time (Sys.time()) as a prefix to files to export. This parameter helps to avoid exported files with the same name. By default TRUE.

quiet

Logical. Suppress info message

...

Extra exporting argument. See ee_image_to_drive and ee_image_to_gcs.

Details

ee_as_stars supports the download of ee$Images by two different options: "drive" (Google Drive) and "gcs" ( Google Cloud Storage). In both cases ee_as_stars works as follow:

For getting more information about exporting data from Earth Engine, take a look at the Google Earth Engine Guide - Export data.

Value

A stars-proxy object

See Also

Other image download functions: ee_as_raster(), ee_as_thumbnail(), ee_imagecollection_to_local()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
## Not run: 
library(rgee)

ee_Initialize(drive = TRUE, gcs = TRUE)
ee_user_info()

# Define an image.
img <- ee$Image("LANDSAT/LC08/C01/T1_SR/LC08_038029_20180810")$
  select(c("B4", "B3", "B2"))$
  divide(10000)

# OPTIONAL display it using Map
Map$centerObject(eeObject = img)
Map$addLayer(eeObject = img, visParams = list(max = 0.4,gamma=0.1))

# Define an area of interest.
geometry <- ee$Geometry$Rectangle(
  coords = c(-110.8, 44.6, -110.6, 44.7),
  proj = "EPSG:4326",
  geodesic = FALSE
)

## drive - Method 01
# Simple
img_02 <- ee_as_stars(
  image = img,
  region = geometry,
  via = "drive"
)

# Lazy
img_02 <- ee_as_stars(
  image = img,
  region = geometry,
  via = "drive",
  lazy = TRUE
)

img_02_result <- img_02 %>% ee_utils_future_value()
attr(img_02_result, "metadata") # metadata

## gcs - Method 02
# Simple
img_03 <- ee_as_stars(
  image = img,
  region = geometry,
  container = "rgee_dev",
  via = "gcs"
)

# Lazy
img_03 <- ee_as_stars(
  image = img,
  region = geometry,
  container = "rgee_dev",
  lazy = TRUE,
  via = "gcs"
)

img_03_result <- img_03 %>% ee_utils_future_value()
attr(img_03_result, "metadata") # metadata

# OPTIONAL: clean containers
ee_clean_container(name = "rgee_backup", type = "drive")
ee_clean_container(name = "rgee_dev", type = "gcs")

## End(Not run)

csaybar/rgee documentation built on March 11, 2021, 5:48 a.m.