load_SAR_matrix: load_SAR_matrix

Description Usage Arguments Value Examples

View source: R/load_and_reshape.R

Description

Given a file path to a SAR raster image in tif format, convert the raster brick of dimensions A x B x C into a matrix of dimensions A*B x C while keeping track of the geospatial and dimension attributes of the original brick. This function uses array_reshape with default order = "C", meaning that elements are read during rearrangement in row-major order, so that the last index changes the fastest.

Usage

1
2
3
4
5
6
load_SAR_matrix(
  filename,
  drop_na = TRUE,
  na_layer = 1L,
  set_na_indices = integer(0)
)

Arguments

filename

This is usually a string giving absolute or relative path to a tif file containing a SAR raster brick. This argument is passed to brick.

drop_na

A logical. If TRUE then any NA pixels are dropped, but a record is kept of their location so that the original raster brick can be easily reconstructed later with matrix_to_brick. Note, to save time, only one layer is checked for NA pixels, i.e., it is assumed that an NA pixel is NA across all layers.

na_layer

An integer specifying the index of the layer to check for NA values if drop_na is TRUE.

set_na_indices

Optional integer vector specifying a vector of row indices in the SAR_matrix that should be replaced by NA pixels.

Value

An object of class SAR_matrix; a specialisation of class matrix.

Examples

1
2
3
4
filename <- system.file(
  "extdata", "MG_CC_sub_norm_testclip.tif", package="rsar")
load_SAR_matrix(filename)
load_SAR_matrix(filename, set_na_indices = c(1,2))

frycast/rsar documentation built on Sept. 4, 2020, 3:52 a.m.