Arithmetic: Arithmetic operators for 'odcr' classes

Description Usage Arguments Value Examples

Description

These arithmetic operators perform arithmetic on two objects of the same class, shape and dimensions.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## S3 method for class 'xarray.core.dataarray.DataArray'
xds + yds

## S3 method for class 'xarray.core.dataarray.DataArray'
xds - yds

## S3 method for class 'xarray.core.dataarray.DataArray'
xds / yds

## S3 method for class 'xarray.core.dataarray.DataArray'
xds * yds

Arguments

xds

xarray object

yds

xarray object

Value

An xarray object of same class, shape and dimensions as the inputs to the operator, holding the result.

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

# connect to a database, store the Daatcube connection internally (default and recommended)
database_connect(app = "Sentinel_2")

# 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)
)

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

ndvi <- (ds[["nir"]] - ds[["red"]]) / (ds[["nir"]] + ds[["red"]])
ndvi


## End(Not run)

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