R: Query data cube values at irregular spatiotemporal points

query_points {gdalcubes} | R Documentation

## Query data cube values at irregular spatiotemporal points

### Description

This function will overlay provided spatiotemporal points with a data cube and return all band values of the cells for each query point, as a data.frame where rows correspond to points and columns represent bands. If needed, point coordinates are automatically transformed to the SRS of the data cube.

### Usage

    query_points(x, px, py, pt, srs)

### Arguments

`x` | source data cube
`px` | vector of x coordinates
`py` | vector of y coordinates
`pt` | vector of date/ time coordinates
`srs` | spatial reference system string identifer (as GDAL understands)

### Details

Date and time of the query points can be provided as vector of class character, Date, or POSIXct.

### Value

a data.frame with one row per point and one column per data cube band or variable

### Examples

    # 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)
    t = seq(as.Date("2018-01-01"), as.Date("2018-12-02"), length.out = 10 )

    query_points(L8.rgb, x, y, t, srs(L8.rgb))

[Package gdalcubes version 0.3.1 Index]