ee_as_raster: Convert an Earth Engine (EE) image into a raster object

Description Usage Arguments Details Value Examples

View source: R/ee_image.R

Description

Convert an Earth Engine (EE) image into a raster object

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
ee_as_raster(
  image,
  region,
  dsn = NULL,
  via = "getInfo",
  scale = NULL,
  maxPixels = 1e+09,
  container = "rgee_backup",
  quiet = FALSE
)

Arguments

image

ee$Image to be converted into a raster object

region

EE Geometry Rectangle (ee$Geometry$Rectangle). The CRS needs to be the same that the x argument otherwise it will be forced. If not specified, image bounds will be taken.

dsn

Character. Output filename. If missing, ee_as_raster will create a temporary file.

via

Character. Method to fetch data about the object. Multiple options supported. See details.

scale

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

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.

container

Character. Name of the folder ('drive') or bucket ('gcs') to be exported into (ignored if via is not defined as "drive" or "gcs").

quiet

Logical. Suppress info message

Details

ee_as_raster supports the download of ee$Image by three different options: "getInfo", "drive", and "gcs". When "getInfo" is set in the via argument, ee_as_raster will make an REST call to retrieve all the known information about the object. The advantage of use "getInfo" is a direct and faster download. However, there is a limitation of 262144 pixels by request which makes it not recommendable for large images. Instead of "getInfo", the options: "drive" and "gcs" are suitable for large collections since they use an intermediate web store service. Before to use any of this options, it is necessary previously install the R packages googledrive and googleCloudStorageR. For getting more information about exporting data take a look at the Google Earth Engine Guide - Export data.

Value

A RasterStack object

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
## Not run: 
library(rgee)

# Initialize a specific Earth Engine account and load
# either Google Drive or Google Cloud Storage credentials
ee_reattach()
ee_Initialize(
  email = "data.colec.fbf@gmail.com",
  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
)

## getInfo - Option 01
img_01 <- ee_as_raster(
  image = img,
  region = geometry,
  via = "getInfo"
)

## drive - Method 02
img_02 <- ee_as_raster(
  image = img,
  region = geometry,
  via = "drive"
)

## gcs - Method 03
img_03 <- ee_as_raster(
  image = img,
  region = geometry,
  container = "rgee_dev",
  via = "gcs"
)

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

## End(Not run)

ryali93/rgee documentation built on May 13, 2020, 4:34 a.m.