-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwritereadrast.Rd
45 lines (39 loc) · 1.43 KB
/
writereadrast.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/writereadrast.R
\name{writereadrast}
\alias{writereadrast}
\title{Write and read back \code{spatRaster}}
\usage{
writereadrast(x, filename, overwrite = TRUE, layernames = NULL)
}
\arguments{
\item{x}{A \code{terra::SpatRaster}}
\item{filename}{A \code{character} file path and name to save \code{x} to disc.}
\item{overwrite}{\code{logical}; overwrite existing raster. \strong{NB:} by default,
\code{overwrite = TRUE}, this is the opposite of the default behaviour of
\code{terra::writeRaster}}
\item{layernames}{\code{character} of length \code{nlyr(x)}}
}
\value{
A \code{terra::SpatRaster} object reading from disc at \code{filename}.
}
\description{
When a new \code{terra::SpatRaster} is created it is stored in
memory. Writing it to disc and reading the object back from file requires two
steps: \code{terra::writeRaster} then reading and re-assigning via \code{terra::rast}.
\code{writereadrast} wraps these into a single step.
}
\examples{
\dontrun{
# create raster then assign
r <- sdmtools::example_raster()
# usual workflow in two slow tedious boring steps
terra::writeRaster(r, "LowerSpringvale.tif")
s <- terra::rast("LowerSpringvale.tif")
Better workflow in one fast enjoyable lithesome step with `sdmtools`
r <- writereadrast(r, "tootgarook.tif")
# or roll into single step with pipe
q <- sdmtools::example_raster() |>
writereadrast("frankstonfreeway.tif")
}
}