query_timeseries: Query data cube timeseries at irregular spatial points

Description Usage Arguments Value Examples

View source: R/query_timeseries.R

Description

This function will overlay provided spatial points with a data cube and return time series of all bands of the cells for each query point, as a list of data.frame (one data frame per band) where rows correspond to points and columns represent time. If needed, point coordinates are automatically transformed to the SRS of the data cube.

Usage

1
query_timeseries(x, px, py, srs)

Arguments

x

source data cube

px

vector of x coordinates

py

vector of y coordinates

srs

spatial reference system string identifer (as GDAL understands)

Value

a list of data.frames (one per band / variable) with one row per point and one column per data cube time slice

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# create image collection from example Landsat data only 
# if not already done in other examples
if (!file.exists(file.path(tempdir(), "L8.db"))) {
  L8_files <- list.files(system.file("L8NY18", package = "gdalcubes"),
                         ".TIF", recursive = TRUE, full.names = TRUE)
  create_image_collection(L8_files, "L8_L1TP", file.path(tempdir(), "L8.db")) 
}
L8.col = image_collection(file.path(tempdir(), "L8.db"))
v = cube_view(extent=list(left=388941.2, right=766552.4, 
              bottom=4345299, top=4744931, t0="2018-01-01", t1="2018-12-02"),
              srs="EPSG:32618", nx = 497, ny=526, dt="P14D")
L8.cube = raster_cube(L8.col, v) 
L8.rgb = select_bands(L8.cube, c("B02", "B03", "B04"))

x = seq(from = 388941.2, to = 766552.4, length.out = 10)
y = seq(from = 4345299, to = 4744931, length.out = 10)

query_timeseries(L8.rgb, x, y, srs(L8.rgb))

gdalcubes documentation built on Oct. 28, 2021, 5:06 p.m.