Skip to contents

The function import the first layer of a generic raster file. Data are imported as an array of x, y, z columns.

Usage

importRaster(
  file = file.choose(),
  k = 1,
  kz = 1,
  dx = 0,
  dy = 0,
  destaggering = FALSE,
  variable = NULL,
  verbose = FALSE
)

Arguments

file

The raster file to be imported.

k

A numerical factor to be applied to x and y coordinates (default = 1).

kz

A numerical factor to be applied to z values (default = 1).

dx

Shifts x coordinates by dx (default = 0).

dy

float. Shift y coordinates by dy (default = 0).

destaggering

Use TRUE to apply destaggering to X and Y coordinates (default = FALSE).

variable

The name of the variable to be imported.

verbose

If TRUE, prints out basic statistics (default = FALSE).

Value

It returns a dataframe with x, y and z columns.

Details

Supported files include those managed by the raster package (as netcdf),

Destaggering is useful for importing data from the SPRAY model and it is not applied by default.

An optional summary output can be printed by setting the verbose parameter.

This function is based on the terra package and it can import any format managed by it.

Examples

if (FALSE) {
# Import binary (netcdf) file and convert coordinates from km to m,
# without destaggering:
mydata <- importRaster(file = "/path_to_file/filename.nc",
                       k = 1000,
                       destaggering = FALSE)

# Import binary (netcdf) file and convert coordinates from km to m,
# with shift of 100 m in both directions:
mydata <- importRaster(file = "/path_to_file/filename.nc",
                       k = 1000,
                       dx = 100,
                       dy = 100)
}