Skip to content

Commit

Permalink
c
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed Oct 12, 2023
1 parent 1eca6de commit 2c4831e
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
5 changes: 2 additions & 3 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion man/movingFun.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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})}
}
Expand Down
2 changes: 1 addition & 1 deletion man/rasterize.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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).
}
Expand Down
2 changes: 1 addition & 1 deletion man/terrain.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}


Expand Down
4 changes: 1 addition & 3 deletions man/writeRaster.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 2c4831e

Please sign in to comment.