read_raster: Methods to create a terra::SpatRaster object with the ability...

View source: R/read_write_idf.r

read_rasterR Documentation

Methods to create a terra::SpatRaster object with the ability to read idf files.

Description

The function 'read_raster' is able to create a terra::SpatRaster object from an idf-file if an idf-filename is specified (exctension '.idf', like in 'foo.idf'). Otherwhise the function equals the function 'terra::rast()'.

Usage

read_raster(x, EPSG = "EPSG:28992", e = NULL, funstr = NULL, ...)

Arguments

x

filename (character)

EPSG

coordinate reference system like "EPSG:4326" (character)

e

Terra extent object

funstr

Optional function to modify raster values. Denote the raster with 'x' (or character between square brackets) (character)

...

Additional arguments as for 'terra::rast' function. For an idf-raster, only the optional 'EPSG' argument is used.

Value

terra::SpatRaster

Examples

f <- system.file("extdata", "test.idf", package="idf")
r <- read_raster(f)

f <- system.file("extdata", "test.tif", package="idf")
r <- read_raster(f)

f <- system.file("extdata", "heads.tif", package="idf")
r <- read_raster(f)
names(r)

f1 <- system.file("extdata", "HEAD_20080401_l1.idf", package="idf")
f2 <- system.file("extdata", "HEAD_20080501_l1.idf", package="idf")
f <- c(f1, f2)
r <- read_raster(f)

r <- read_raster(f, funstr="x*100")

KeesVanImmerzeel/idf documentation built on Jan. 13, 2025, 3:23 a.m.