From 0a60b8e98bb57b1e5e58f0caea96cc466be3ff70 Mon Sep 17 00:00:00 2001 From: Adrian Baddeley Date: Sat, 12 Feb 2022 14:27:03 +0800 Subject: [PATCH] Tidied up, submitted to CRAN as 2.3-2 --- DESCRIPTION | 5 ++--- NEWS | 4 ++-- R/as.im.R | 32 +++++++++++++++++++++++--------- R/distancemetrics.R | 4 ++-- R/nnutils.R | 6 +++--- inst/doc/packagesizes.txt | 2 +- man/matchingdist.Rd | 2 +- man/pppdist.Rd | 2 +- man/pppmatching.Rd | 2 +- man/pppmatching.object.Rd | 2 +- 10 files changed, 37 insertions(+), 24 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index a6b3c93..0e8661e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: spatstat.geom -Version: 2.3-1.001 -Date: 2022-02-11 +Version: 2.3-2 +Date: 2022-02-12 Title: Geometrical Functionality of the 'spatstat' Family Authors@R: c(person("Adrian", "Baddeley", role = c("aut", "cre"), @@ -22,7 +22,6 @@ Maintainer: Adrian Baddeley Depends: R (>= 3.5.0), spatstat.data (>= 2.0-0), stats, graphics, grDevices, utils, methods Imports: spatstat.utils (>= 2.2-0), deldir (>= 1.0-2), polyclip (>= 1.10-0) Suggests: spatstat.core, spatstat.random, spatstat.linnet, maptools (>= 0.9-9), spatial, fftwtools (>= 0.9-8), spatstat (>= 2.0-0) -Additional_repositories: https://spatstat.r-universe.dev Description: Defines spatial data types and supports geometrical operations on them. Data types include point patterns, windows (domains), pixel images, line segment patterns, tessellations and hyperframes. diff --git a/NEWS b/NEWS index b23cabf..c042c94 100644 --- a/NEWS +++ b/NEWS @@ -1,10 +1,10 @@ - CHANGES IN spatstat.geom VERSION 2.3-1.001 + CHANGES IN spatstat.geom VERSION 2.3-2 OVERVIEW o 'spatstat.geom' now suggests the package 'spatstat.random'. - o Updated help files. + o Updated help files to refer to 'spatstat.random'. CHANGES IN spatstat.geom VERSION 2.3-1 diff --git a/R/as.im.R b/R/as.im.R index fad404d..2fdd446 100644 --- a/R/as.im.R +++ b/R/as.im.R @@ -3,7 +3,7 @@ # # conversion to class "im" # -# $Revision: 1.59 $ $Date: 2021/06/30 08:23:24 $ +# $Revision: 1.60 $ $Date: 2022/02/12 06:09:33 $ # # as.im() # @@ -361,9 +361,13 @@ wrangle2image <- function(values, template) { template <- as.im(template) tdim <- dim(template) nt <- prod(tdim) - vdim <- dim(values) # may be NULL + if(!is.null(vlev <- levels(values))) { + ## flatten and convert to integer + if(!is.factor(values)) values <- factor(values, levels=vlev) + values <- as.integer(values) + } nv <- length(values) - vlev <- levels(values) + vdim <- dim(values) # may be NULL vnames <- NULL if(is.null(vdim)) { ## vector or factor of values @@ -393,17 +397,27 @@ wrangle2image <- function(values, template) { } ## values is now a matrix or array if(is.matrix(values)) { - result <- template - result[drop=FALSE] <- values + if(!is.null(vlev)) values <- factor(values, labels=vlev) + result <- im(values, + xcol=template$xcol, + yrow=template$yrow, + xrange=template$xrange, + yrange=template$yrange, + unitname=unitname(template)) result <- result[W, drop=FALSE] } else { m <- dim(values)[3L] result <- vector(mode="list", length=m) for(i in seq_len(m)) { - Z <- template - Z[drop=FALSE] <- values[,,i] - Z <- Z[W, drop=FALSE] - result[[i]] <- Z + vi <- values[,,i] + if(!is.null(vlev)) vi <- factor(vi, labels=vlev) + Z <- im(vi, + xcol=template$xcol, + yrow=template$yrow, + xrange=template$xrange, + yrange=template$yrange, + unitname=unitname(template)) + result[[i]] <- Z[W, drop=FALSE] } names(result) <- vnames result <- as.solist(result) diff --git a/R/distancemetrics.R b/R/distancemetrics.R index 352dd9c..1a700ba 100644 --- a/R/distancemetrics.R +++ b/R/distancemetrics.R @@ -3,7 +3,7 @@ #' #' Metrics on the spatial domain #' -#' $Revision: 1.11 $ $Date: 2021/09/05 11:22:57 $ +#' $Revision: 1.12 $ $Date: 2022/02/12 06:11:18 $ #' #' An object of class 'metric' is essentially a named list of functions #' where the names specify the tasks. @@ -66,7 +66,7 @@ warn.no.metric.support <- function(caller, ..., metric) { warn.unsupported.args <- function(unsup, ...) { given <- list(...) - if(any(hit <- names(unsup) %in% names(given))) { + if(any(names(unsup) %in% names(given))) { values <- resolve.defaults(given, unsup)[names(unsup)] changed <- !mapply(identical, x=unsup, y=values) if(any(changed)) { diff --git a/R/nnutils.R b/R/nnutils.R index 311c7c2..c0096fb 100644 --- a/R/nnutils.R +++ b/R/nnutils.R @@ -3,7 +3,7 @@ #' #' Utilities for extracting nndist/nncross from distance matrices #' -#' $Revision: 1.3 $ $Date: 2021/09/26 07:32:16 $ +#' $Revision: 1.4 $ $Date: 2022/02/12 06:12:14 $ PDtoNN <- function(d, what=c("dist", "which"), k=1L, ...) { @@ -17,7 +17,7 @@ PDtoNN <- function(d, what=c("dist", "which"), k=1L, ...) { what <- match.arg(what, several.ok=TRUE) want.dist <- "dist" %in% what want.which <- "which" %in% what - want.both <- want.dist && want.which + ## want.both <- want.dist && want.which if(!missing(k)) { # k can be a single integer or an integer vector @@ -87,7 +87,7 @@ XDtoNN <- function(d, what=c("dist", "which"), what <- match.arg(what, several.ok=TRUE) want.dist <- "dist" %in% what want.which <- "which" %in% what - want.both <- want.dist && want.which + ## want.both <- want.dist && want.which if(!missing(k)) { # k can be a single integer or an integer vector diff --git a/inst/doc/packagesizes.txt b/inst/doc/packagesizes.txt index 393a293..4c870d9 100755 --- a/inst/doc/packagesizes.txt +++ b/inst/doc/packagesizes.txt @@ -9,4 +9,4 @@ date version nhelpfiles nobjects ndatasets Rlines srclines "2021-06-15" "2.2-0" 434 1159 0 33744 15115 "2021-10-09" "2.3-0" 440 1175 0 34553 15173 "2021-12-10" "2.3-1" 440 1176 0 34643 15173 -"2022-02-11" "2.3-1.001" 440 1176 0 34643 15173 +"2022-02-12" "2.3-2" 440 1176 0 34657 15173 diff --git a/man/matchingdist.Rd b/man/matchingdist.Rd index 8c6d141..490adce 100644 --- a/man/matchingdist.Rd +++ b/man/matchingdist.Rd @@ -62,7 +62,7 @@ \author{ Dominic Schuhmacher \email{dominic.schuhmacher@stat.unibe.ch} - \url{http://dominic.schuhmacher.name/} + URL \code{http://dominic.schuhmacher.name/} } \seealso{ \code{\link{pppdist}} diff --git a/man/pppdist.Rd b/man/pppdist.Rd index fae65eb..d21684a 100644 --- a/man/pppdist.Rd +++ b/man/pppdist.Rd @@ -178,7 +178,7 @@ \author{ Dominic Schuhmacher \email{dominic.schuhmacher@mathematik.uni-goettingen.de} \cr - \url{http://dominic.schuhmacher.name/} + URL \code{http://dominic.schuhmacher.name/} } \seealso{ \code{\link{pppmatching.object}}, \code{\link{matchingdist}}, diff --git a/man/pppmatching.Rd b/man/pppmatching.Rd index 8f027db..d257d7c 100644 --- a/man/pppmatching.Rd +++ b/man/pppmatching.Rd @@ -46,7 +46,7 @@ \author{ Dominic Schuhmacher \email{dominic.schuhmacher@stat.unibe.ch} - \url{http://dominic.schuhmacher.name/} + URL \code{http://dominic.schuhmacher.name/} } \seealso{ \code{\link{pppmatching.object}} diff --git a/man/pppmatching.object.Rd b/man/pppmatching.object.Rd index f1e8aba..1838525 100644 --- a/man/pppmatching.object.Rd +++ b/man/pppmatching.object.Rd @@ -56,7 +56,7 @@ \author{ Dominic Schuhmacher \email{dominic.schuhmacher@stat.unibe.ch} - \url{http://dominic.schuhmacher.name/} + URL \code{http://dominic.schuhmacher.name/} } \seealso{ \code{\link{matchingdist}},