From 5a4c18a88be27a89fc6f07df33f0b18410e97e99 Mon Sep 17 00:00:00 2001 From: rhijmans Date: Mon, 9 Oct 2023 02:05:41 -0700 Subject: [PATCH] doc --- R/generics.R | 8 ++++++-- R/geom.R | 7 +++++++ man/geomtype.Rd | 2 -- man/is.bool.Rd | 5 ++--- man/is.valid.Rd | 5 +++++ 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/R/generics.R b/R/generics.R index 59b407c65..2bf3e0109 100644 --- a/R/generics.R +++ b/R/generics.R @@ -974,8 +974,12 @@ setMethod("stretch", signature(x="SpatRaster"), function(x, minv=0, maxv=255, minq=0, maxq=1, smin=NA, smax=NA, histeq=FALSE, scale=1, maxcell=500000, filename="", ...) { if (histeq) { if (nlyr(x) > 1) { - warn("stretch", "only the first layer of x is used") - x <- x[[1]] + x <- lapply(1:nlyr(x), function(i) stretch(x[[i]], histeq=TRUE, scale=scale, maxcell=maxcell)) + x <- rast(x) + if (filename != "") { + x <- writeRaster(x, filename=filename, ...) + } + return(x) } scale <- scale[1] if (scale == 1) { diff --git a/R/geom.R b/R/geom.R index c7020e641..ee0da48d0 100644 --- a/R/geom.R +++ b/R/geom.R @@ -718,3 +718,10 @@ setMethod("forceCCW", signature(x="SpatVector"), messages(x) } ) + + +setMethod("is.empty", signature(x="SpatVector"), + function(x) { + nrow(x) == 0 + } +) diff --git a/man/geomtype.Rd b/man/geomtype.Rd index ee8ff072f..a9614e132 100644 --- a/man/geomtype.Rd +++ b/man/geomtype.Rd @@ -22,8 +22,6 @@ Get the geometry type (points, lines, or polygons) of a SpatVector. See \code{\l \usage{ \S4method{geomtype}{SpatVector}(x) -\S4method{datatype}{SpatVector}(x) - \S4method{is.points}{SpatVector}(x) \S4method{is.lines}{SpatVector}(x) diff --git a/man/is.bool.Rd b/man/is.bool.Rd index 409000baf..5935947c4 100644 --- a/man/is.bool.Rd +++ b/man/is.bool.Rd @@ -27,6 +27,8 @@ The values in a SpatRaster layer are by default numeric, but they can also be se For a \code{SpatRaster}, \code{as.logical} and \code{isTRUE} is equivalent to \code{as.bool}. \code{isFALSE} is equivalent to \code{!as.bool}, and \code{as.integer} is the same as \code{as.int}. +\code{as.bool} and \code{as.int} force the values into the correct range (e.g. whole integers) but in-memory cell values are still stored as numeric. They will behave like the assigned types, though, and will be written to files with that data type (if the file type supports it). + See \code{\link{levels}} and \code{\link{cats}} to create categorical layers by setting labels. } @@ -44,9 +46,6 @@ See \code{\link{levels}} and \code{\link{cats}} to create categorical layers by \S4method{as.factor}{SpatRaster}(x) } -\description{ -\code{as.bool} and \code{as.int} force the values into the correct range (e.g. whole integers) but in-memory cell values are still stored as numeric. They will behave like the assigned types, though, and will be written to files with that data type (if the file type supports it). -} \arguments{ \item{x}{SpatRaster} diff --git a/man/is.valid.Rd b/man/is.valid.Rd index 144299db3..aa41a6a7d 100644 --- a/man/is.valid.Rd +++ b/man/is.valid.Rd @@ -1,5 +1,6 @@ \name{is.valid} +\alias{is.empty} \alias{is.valid} \alias{is.valid,SpatVector-method} \alias{is.valid,SpatExtent-method} @@ -19,6 +20,10 @@ Check the validity of polygons or attempt to fix it. Or check the validity of a \S4method{makeValid}{SpatVector}(x) \S4method{is.valid}{SpatExtent}(x) + +\S4method{is.empty}{SpatExtent}(x) + +\S4method{is.empty}{SpatVector}(x) } \arguments{