datacube: Query a datacube

Description Usage Arguments Value Examples

Description

These functions query a datacube to which a connection has been established using database_connect.

Usage

1
2
3
4
5
6
7
8
9
dc_close(dc = getOption("odcr.dc"))

dc_find_datasets(dc = getOption("odcr.dc"), query, lazy = FALSE)

dc_list_measurements(dc = getOption("odcr.dc"))

dc_list_products(dc = getOption("odcr.dc"))

dc_load(dc = getOption("odcr.dc"), query)

Arguments

dc

a datacube connection of class 'datacube.api.core.Datacube'. By default, the session connection initialized using connect() is used.

query

list, containing query parameters such as

  • 'product', character, name of the product to be queries (see dc_list_products())

  • 'time', character vector of length == 2, containing a time query

  • 'x', numeric vector of length == 2, containing xmin and xmax

  • 'y', numeric vector of length == 2, containing ymin and ymax

  • 'output_crs', character, the output CRS, e.g. as epsg in the format 'epsg:6933'

  • 'resolution', numeric vector of length == 2

  • 'measurements', character vector containing the names or aliases of measurements

lazy

logical, whether to use lazy dataset finding or not.

Value

None or data.frame

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

# connect to a database
database_connect(app = "Sentinel_2")

# return a data.frame containing all stored variables/measurements of the current connection
# and its aliases, data types etc.
dc_list_measurements()

# return a data.frame containing all products of the current connection
dc_list_products()

# build a query list
lat <- 22.821
lon <- 28.518
buffer <- 0.05

query <- list(
  'time' = c('2020-01', '2020-03'),
  'x' = c(lon - buffer, lon + buffer),
  'y' = c(lat + buffer, lat - buffer),
  'output_crs' = 'epsg:6933',
  'resolution' = c(-20,20)
)

# return a data.frame of all datasets matching the query
dc_find_datasets(query = c(product = "s2_l2a", query))

# load data and return an xarray object for a query
ds <- dc_load(query = c(product = "s2_l2a", dask_chunks = dict(), query))

# after a lot of queries, you may want to close open connections
dc_close()

## End(Not run)

eo2cube/odcr documentation built on Dec. 20, 2021, 5:21 a.m.