From 2c4831efba2796020436347861e79f25f748b020 Mon Sep 17 00:00:00 2001 From: rhijmans Date: Thu, 12 Oct 2023 17:31:45 +0200 Subject: [PATCH] c --- DESCRIPTION | 4 ++-- NEWS | 5 ++--- man/movingFun.Rd | 2 +- man/rasterize.Rd | 2 +- man/terrain.Rd | 2 +- man/writeRaster.Rd | 4 +--- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 612255be..578ddea5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: raster Type: Package Title: Geographic Data Analysis and Modeling -Version: 3.6-24 -Date: 2023-10-05 +Version: 3.6-26 +Date: 2023-10-12 Imports: Rcpp, methods, terra (>= 1.7-29) LinkingTo: Rcpp Depends: sp (>= 1.4-5), R (>= 3.5.0) diff --git a/NEWS b/NEWS index 339fd63a..83938cc6 100644 --- a/NEWS +++ b/NEWS @@ -55,12 +55,11 @@ calc failed when writing to disk if the supplied function returned multiple laye reclassify bug reported by Jacub Nowasad. https://github.com/rspatial/raster/issues/62 extract failed for sf objects with a Z dimension. https://github.com/rspatial/raster/issues/64 -More generics and namespace exports for compatability with "terra" +More generics and namespace exports for compatibility with "terra" --- 10-July-2019, version: 2.9-22 New (hidden) function ".ifel", that is, ifelse for Raster objects (this is the R implementation of the arcpy "Con" method) -New (hidden) function ".ifel", that is, ifelse for Raster objects (this is the R implementation of the arcpy "Con" method) -Lots of namespace export additions for compatability with "terra" +Lots of namespace export additions for compatibility with "terra" Old .Call code replaced with Rcpp based code Bug fixes: diff --git a/man/movingFun.Rd b/man/movingFun.Rd index f4704c8f..f0d00d52 100644 --- a/man/movingFun.Rd +++ b/man/movingFun.Rd @@ -17,7 +17,7 @@ movingFun(x, n, fun=mean, type='around', circular=FALSE, na.rm=FALSE) \item{x}{A vector of numbers} \item{n}{Size of the 'window', i.e. the number of sequential elements to use in the function} \item{fun}{A function like mean, min, max, sum} - \item{type}{Character. One of 'around', 'to', or 'from'. The choice indicates which values should be used in the computation. The focal element is always used. If \code{type} is 'around', the other elements are before and after the focal element. Alternatively, you can select the elements preceding the focal element ('to') or those coming after it {'from'}. For example, to compute the movingFun with \code{n=3} for element 5 of a vector; 'around' used elements 4,5,6; 'to' used elements 3,4,5, and 'from' uses elements 5,6,7} + \item{type}{Character. One of 'around', 'to', or 'from'. The choice indicates which values should be used in the computation. The focal element is always used. If \code{type} is 'around', the other elements are before and after the focal element. Alternatively, you can select the elements preceding the focal element ('to') or those coming after it ('from'). For example, to compute the movingFun with \code{n=3} for element 5 of a vector; 'around' used elements 4,5,6; 'to' used elements 3,4,5, and 'from' uses elements 5,6,7} \item{circular}{Logical. If \code{TRUE}, the data are considered to have a circular nature (e.g. months of the year), and the last elements in vector \code{x} are used in the computation of the moving function of the first element(s) of the vector, and the first elements are used in the computation of the moving function for the last element(s)} \item{na.rm}{Logical. If \code{TRUE}, \code{NA} values should be ingored (by \code{fun})} } diff --git a/man/rasterize.Rd b/man/rasterize.Rd index 830ebf68..9b5e7621 100644 --- a/man/rasterize.Rd +++ b/man/rasterize.Rd @@ -46,7 +46,7 @@ If \code{x} represents points, each point is assigned to a grid cell. Points tha \item{fun}{function or character. To determine what values to assign to cells that are covered by multiple spatial features. You can use functions such as \code{min, max}, or \code{mean}, or one of the following character values: \code{'first'}, \code{'last'}, \code{'count'}. The default value is \code{'last'}. In the case of SpatialLines*, \code{'length'} is also allowed (currently for planar coordinate systems only). -If \code{x} represents points, \code{fun} must accept a \code{na.rm} argument, either explicitly or through 'dots'. This means that \code{fun=length} fails, but \code{fun=function(x,...)length(x)} works, although it ignores the \code{na.rm} argument. To use the \code{na.rm} argument you can use a function like this: fun=function(x, na.rm){if (na.rm) length(na.omit(x)) else (length(x)}, or use a function that removes \code{NA} values in all cases, like this function to compute the number of unique values per grid cell "richness": \code{fun=function(x, ...) {length(unique(na.omit(x)))} }. If you want to count the number of points in each grid cell, you can use \code{ fun='count'} or \code{fun=function(x,...){length(x)}}. +If \code{x} represents points, \code{fun} must accept a \code{na.rm} argument, either explicitly or through the ellipses ('dots'). This means that \code{fun=length} fails, but \code{fun=function(x,...)length(x)} works, although it ignores the \code{na.rm} argument. To use the \code{na.rm} argument you can use a function like this: \code{fun=function(x, na.rm){if (na.rm) length(na.omit(x)) else (length(x)}}, or use a function that removes \code{NA} values in all cases, like this function to compute the number of unique values per grid cell "richness": \code{fun=function(x, ...) {length(unique(na.omit(x)))} }. If you want to count the number of points in each grid cell, you can use \code{ fun='count'} or \code{fun=function(x,...){length(x)}}. You can also pass multiple functions using a statement like \code{fun=function(x, ...) c(length(x),mean(x))}, in which case the returned object is a RasterBrick (multiple layers). } diff --git a/man/terrain.Rd b/man/terrain.Rd index 3df3bb8e..883b5cd0 100644 --- a/man/terrain.Rd +++ b/man/terrain.Rd @@ -47,7 +47,7 @@ TRI <- focal(x, w=f, fun=function(x, ...) sum(abs(x[-5]-x[5]))/8, pad=TRUE, padV TPI <- focal(x, w=f, fun=function(x, ...) x[5] - mean(x[-5]), pad=TRUE, padValue=NA) -rough <- focal(x, w=f, fun=function(x, ...) {max(x) - min(x)}, pad=TRUE, padValue=NA, na.rm=TRUE) +rough <- focal(x, w=f, fun=function(x, ...) max(x) - min(x), pad=TRUE, padValue=NA, na.rm=TRUE) } diff --git a/man/writeRaster.Rd b/man/writeRaster.Rd index ecdff1d0..252affa2 100644 --- a/man/writeRaster.Rd +++ b/man/writeRaster.Rd @@ -25,9 +25,7 @@ When writing a file to disk, the file format is determined by the 'format=' argu \item{format}{Character. Output file type. See \code{\link[raster]{writeFormats}}. If this argument is not provided, it is attempted to infer it from the filename extension. If that fails, the default format is used. The default format is 'raster', but this can be changed using \code{\link{rasterOptions}}} \item{...}{Additional arguments: -\code{datatype}{Character. Output data type (e.g. 'INT2S' or 'FLT4S'). -See \code{\link{dataType}}. If no datatype is specified, 'FLT4S' is used, -unless this default value was changed with \code{\link{rasterOptions}}} +\code{datatype}: Character. Output data type (e.g. 'INT2S' or 'FLT4S'). See \code{\link{dataType}}. If no datatype is specified, 'FLT4S' is used, unless this default value was changed with \code{\link{rasterOptions}} \code{overwrite}: Logical. If TRUE, "filename" will be overwritten if it exists