importRaster: Import generic raster file

View source: R/importRaster.R

importRasterR Documentation

Import generic raster file

Description

A function to import the first layer of a generic raster file.

Usage

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

Arguments

file

character. Path to the raster file.

k

numeric. Factor applied to x and y coordinates (default = 1). For example, it can be used to convert the grid coordinates from km to m (k = 1000).

kz

numeric. Factor applied to the variable values (default = 1).

dx

numeric. Constant to shift x coordinates (default = 0).

dy

numeric. Constant to shift y coordinates (default = 0).

destaggering

Use TRUE to apply destaggering to X and Y coordinates (default = FALSE). See the Details section.

variable

character. The name of the variable to be imported.

verbose

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

Details

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

Destaggering applies a shift equal to half grid size in both horizontal directions. It is useful for importing data from the SPRAY air quality dispoersion model and it is not applied by default.

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

Value

A data.frame with x, y and z columns for the grid cells coordiantes and the variable value.

See Also

importADSOBIN(), importSurferGrd()

Examples

## Not run: 
# Import binary (netcdf) file and convert coordinates from km to m,
# without destaggering. Variable name is "NOx".
mydata <- importRaster(
    file = "/path_to_file/filename.nc",
    variable = "NOx",
    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",
    variable = "pm10",
    k = 1000,
    dx = 100,
    dy = 100
)

## End(Not run)

simulariatools documentation built on Sept. 1, 2025, 5:09 p.m.