GithubHelp home page GithubHelp logo

spatstat / spatstat.geom Goto Github PK

View Code? Open in Web Editor NEW
7.0 7.0 3.0 1.49 MB

Sub-package of spatstat defining spatial data and spatial/geometrical operations

R 76.81% Makefile 0.08% C 23.10%
classes-and-objects distance-calculation geometry geometry-processing images mensuration plotting point-patterns spatial-data spatial-data-analysis

spatstat.geom's Introduction

spatstat

spatstat is a family of R packages for analysing spatial point pattern data (and other kinds of spatial data). It has extensive capabilities for exploratory analysis, statistical modelling, simulation and statistical inference.

See the website www.spatstat.org or read the book.

spatstat has been split into a family of packages

Originally there was a single package called spatstat. It grew so large that CRAN required us to split it into pieces.

The original spatstat has now been divided into a family of 10 sub-packages:

Sub-package CRAN page GitHub repository Description
spatstat.utils CRAN_Status_Badge GitHub R package version Basic utilities
spatstat.data CRAN_Status_Badge GitHub R package version Datasets
spatstat.sparse CRAN_Status_Badge GitHub R package version Sparse arrays
spatstat.univar CRAN_Status_Badge GitHub R package version 🆕 Univariate probability distributions 🦘
spatstat.geom CRAN_Status_Badge GitHub R package version Spatial data classes; geometrical operations
spatstat.random CRAN_Status_Badge GitHub R package version Generation of random patterns
spatstat.explore CRAN_Status_Badge GitHub R package version Exploratory Data Analysis of spatial data
spatstat.model CRAN_Status_Badge GitHub R package version Parametric modelling and formal inference for spatial data
spatstat.linnet CRAN_Status_Badge GitHub R package version Spatial analysis on a linear network
spatstat CRAN_Status_Badge GitHub R package version Umbrella package

Click the green badge to visit the CRAN page which contains the current release of each sub-package. Click the blue badge to visit the GitHub repository for the current development version of the sub-package.

There still exists a package called spatstat, which is now an umbrella package that requires all the sub-packages listed above.

You can install and load the new spatstat family in virtually the same way as you would previously have installed and loaded the old spatstat package. When you install the new umbrella package spatstat, all the sub-packages listed above will be installed. When you load the new umbrella spatstat package in an R session, all the sub-packages listed above will be loaded or imported.

Extension packages

Additionally there are extension packages which contain more functionality. These packages are not automatically installed or loaded; the user must do that if these extra features are desired.

Extension package CRAN page GitHub repository Description
spatstat.gui CRAN_Status_Badge GitHub R package version Graphical interface
spatstat.Knet CRAN_Status_Badge GitHub R package version linear networks
spatstat.local CRAN_Status_Badge GitHub R package version Local (geographically weighted) models
spatstat.sphere Not yet published GitHub R package version Spherical data

Family portrait

The pink box marked spatstat contains all the code that will be installed when you install the spatstat umbrella package, and loaded or imported when you load the spatstat umbrella package.

The blue boxes are extension packages which must be installed and loaded separately.

Spatstat pieces

Future development

spatstat is the result of 30 years of software development and contains over 180,000 lines of code. It is still under development, motivated by the needs of researchers in many fields, and driven by innovations in statistical science. We welcome contributions of code, and suggestions for improvements.

spatstat.geom's People

Contributors

baddstats avatar rubak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

spatstat.geom's Issues

as.owin() function now follows bbox instead of polygon geometry

My goal is to create an owin object from a sfc_POLYGON object. I recently migrated to 'spatstat.geom' v1.65-5 from 'spatstat' v1.64-1 and I noticed the as.owin() function produces different output between the two packages.

lapply(c("spatstat", "spatstat.geom", "sf", "sp") , library, character.only = TRUE)

# Create SpatialPolygons
x_coords <- c(-60,-60,-62,-61,-62,-60)
y_coords <- c(20,25,25,22,20,20)
spPoly <- sp::Polygon(cbind(x_coords,y_coords))
spPolys <- sp::Polygons(list(spPoly), ID = "A")
spPolys <- sp::SpatialPolygons(list(spPolys))

# Convert to 'sfc_POLYGON'
sfPolys <- sf::st_as_sf(spPolys)

# SpatialPolygons
plot(sfPolys)

# spatstat v1.64-1
test1 <- spatstat::as.owin(sf::st_geometry(sfPolys)) 
plot(test1) # owin similar to polygon

# spatstat.geom v1.65-5
test2 <- spatstat.geom::as.owin(sf::st_geometry(sfPolys))
plot(test2) # owin similar to bbox

Can you recommend a solution? Thank you!

Extend implementation of weighted median

This is a continuation of issue spatstat/spatstat/#128 which was raised for the original spatstat package, but now affects spatstat.geom.

The original poster argued that our code for weighted.median was incorrect.

However the issue is really that there are multiple definitions of the weighted median (as there are for the unweighted median).

We are now interpreting this as a feature request to implement other definitions of the weighted median.

`weighted.median` not in line with unweighted median on repeated entries

The documentation of the weighted.median states that the resulting value will be

...a value m such that the total weight of data less than or equal to m is equal to half the total weight.

The documentation though does not state a source for that statement. To my understanding the equal to is questionable, the median should 'strictly' halve the dataset. A different algorithm specifically states that the equals to (if applicable) is applicable in both direction (up and down): https://rdrr.io/cran/matrixStats/man/weightedMedian.html (although the wording also is not 100% clear).

I know that this question is similar to the ones asked here spatstat/spatstat#128 and here #5 but the given solution does not fully answer my question.

In the following example, I expect the median and the weighted median to be equal. Where am I having a misunderstanding?

library(spatstat)
#> Lade nötiges Paket: spatstat.data
#> Lade nötiges Paket: spatstat.geom
#> spatstat.geom 3.2-9
#> Lade nötiges Paket: spatstat.random
#> spatstat.random 3.2-3
#> Lade nötiges Paket: spatstat.explore
#> Lade nötiges Paket: nlme
#> spatstat.explore 3.2-7
#> Lade nötiges Paket: spatstat.model
#> Lade nötiges Paket: rpart
#> spatstat.model 3.2-11
#> Lade nötiges Paket: spatstat.linnet
#> spatstat.linnet 3.1-5
#> 
#> spatstat 3.0-8 
#> For an introduction to spatstat, type 'beginner'
weighted.median(c(1,2,3), c(1,1,1))
#> [1] 1.5
median(c(1,2,3))
#> [1] 2

weighted.median(c(1,2,3), c(2,1,1))
#> [1] 1
median(c(1,1,2,3))
#> [1] 1.5

weighted.median(c(1,2,3,4), c(1,1,1,1))
#> [1] 2
median(c(1,2,3,4))
#> [1] 2.5

Created on 2024-04-29 with reprex v2.1.0

Bug in new code in `crosspairs.ppp()`

Reproducible example here:

https://stackoverflow.com/q/72616066/3341769

The underlying issue is that the number of points nX and nY both are integer and when they are sufficiently large the product nXY = nX*nY overflows:

> 8000L*1000000L
[1] NA
Warning message:
In 8000L * 1000000L : NAs produced by integer overflow

This did not happen with the old version of the code that overestimated the number of pairs in another way.

We could simply coerce to double when calculating the product: nXY = as.double(nX) * as.double(nY)

Afterwards this overestimate is improved and checked against .Machine$integer.max so I don't see any problem with nXY being a double, but I may be missing something.

spatstat.sparse dependency

Thank you for providing the "owin" functionality as a separate package. I think this move makes a lot of sense.

I just stumbled on the following minor detail of the new spatstat structure: why would the new spatstat.geom need to import functionality for sparse 3D arrays? I've checked which functions from spatstat.sparse are currently used by spatstat.geom:

  1. spatstat.sparse::RelevantNA() is used only once in as.im.data.frame()
  2. spatstat.sparse::grokIndexVector() is used only once in ppsubset()

In the first case, RelevantNA(zk) could simply be replaced by vector(typeof(zk))[1L].
To resolve the second dependency, maybe the function grokIndexVector() could be moved to spatstat.utils, which both spatstat.sparse and spatstat.geom import anyway? grokIndexVector() itself only needs sortunique(), which is part of spatstat.utils.
After these changes, spatstat.geom would no longer need to depend on spatstat.sparse (with additional recursive dependencies abind and tensor).

Bug in `nncross.ppp` when `iX, iY` are given

nncross.ppp produces wrong answers in the following example:

A <- data.frame(
          m= c("K", "K", "A1", "A2", "G", "A2", "A3"),
          x=c(4.85, 6.76, 10.58, 19.18, 15.74, 19.08, 12.27),
          y=c(5.60, 12.92, 11.14, 17.22, 5.74, 1.24, 2.20),
         stringsAsFactors=TRUE
 )
 X <- with(A, ppp(x, y, marks=m, window=bounding.box.xy(x, y)))
 wrong <- nncross(X, X[7], iX=1:7, iY=7L)$dist
 right <- pairdist(X)[,7]
 right[7] <- Inf
 right
 wrong

nncross returns Inf when k>1 and when k is integer vector

The example code for third-nearest neighbor reproduces the error but on my code it strangely works for some points but not for others. It returns the correct "which" points.

#First to third nearest neighbours return Inf
NXY <- nncross(X, Y, k=1:3)
NXY[1:3,]
dist.1 dist.2 dist.3 which.1 which.2 which.3
1 Inf Inf Inf 7 1 4
2 Inf Inf Inf 14 3 9
3 Inf Inf Inf 7 17 19
#Using k=1 returns the correct distances
NXY <- nncross(X, Y, k=1)
NXY[1:3,]
dist which
1 0.08885846 7
2 0.01831034 14
3 0.13885983 7

plot.solist with equal.ribbon=TRUE uses the ribbon of the first item in list only

I have a list of images created using solist and when I try to plot them with ribbon=TRUE the ribbon only contains the color map of the first image in the list. See the resulting attached image for example. Notice that the species corresponding to the lavender color in years after 1994 is not included in the ribbon. If I change the order of the list the ribbon will change.

This might be as intended but is there a way to have the ribbon include all species?

Dominant_small_.pdf

Can't install spatstat.geom on Windows 10 (R version: 4.1.2)

Hi:
I'm trying to install Seurat and one of the necessary packages to do so is spatstat.geom. When I try to install it, I get this error message:

No se esperaba "zareadiff.o auctionbf.o bdrymask.o close3pair.o closepair.o connect.o dinfty.o discarea.o discs.o dist2dpath.o distan3.o distances.o distmapbin.o dwpure.o exactPdist.o exactdist.o fardist.o hasclose.o hotrod.o init.o knndistance.o knngrid.o loccum.o metricPdist.o minnnd.o nearestpix.o nn3Ddist.o nnMDdist.o nndistance.o nngrid.o periodic.o poly2im.o quasirandom.o raster.o rasterfilter.o scan.o seg2pix.o tabnum.o trigraf.o uniquemap.o veegraf.o whist.o xyseg.o" en este momento.
make: *** [spatstat.geom.dll] Error 255
ERROR: compilation failed for package 'spatstat.geom'
* removing 'C:/Users/jvalf/Documents/R/win-library/4.1/spatstat.geom'
Warning in install.packages :
installation of package ‘spatstat.geom’ had non-zero exit status

Have you ever encountered this problem and know how to solve it? Thanks in advance.

quadratcount issue

First, thanks for the great package. There appears to be an error when passing tesselation data to quadratcount

E.g., the following code yields "Error: object 'Xcount' not found"

library(spatstat)
## Regular Point Grid
tess_y <-  tess_x <- seq(0,1,length.out=6)
tess_im <- tess(xgrid=tess_x, ygrid=tess_y)

## Counts of Point Process
X  <- rpoint(12, function(x,y) { (x^2 + y^2)^2} )
Nx <- quadratcount(X, tess=tess_im)

Owin window changes through operations

I have a set of georeferenced points and I would like to describe their local spatial distribution pattern using the Clark-Evans index.

I'm willing to rasterise the results bu I didn't find any "direct" solution. Hence I tried to convert pixels to polygons [poly object, a SpatVector from terra package] and use them in a loop as a window for spatstat.core::clarkevans(spatstat.geom::ppp(data$X,data$Y, win=as.owin(ext(poly[1])@ptr$vector))) but points are dropped because they're considered outside the window:

> spatstat.geom::ppp(data$X,data$Y, win=as.owin(ext(poly[1])@ptr$vector))

Planar point pattern: 0 points
window: rectangle = [0, 1] x [0, 1] units
*** 3628312 illegal points stored in attr(,“rejects”) ***
Warning message:
3628312 points were rejected as lying outside the specified window 

I checked the window alone and I get what looks like a correct one (correct CRS and pixel dimension, i.e. 1x1m):

> windb = as.owin(ext(rp[cp])@ptr$vector)
> windb
window: rectangle = [740703, 740704] x [5166180, 5166181] units

but when I create a ppp object the window shows a different extent:

> mypoints = spatstat.geom::ppp(data$X,data$Y, win=as.owin(ext(poly[1])@ptr$vector))

> str( mypoints )
List of 5
 $ window    :List of 4
  ..$ type  : chr "rectangle"
  ..$ xrange: num [1:2] 0 1
  ..$ yrange: num [1:2] 0 1
  ..$ units :List of 3
  .. ..$ singular  : chr "unit"
  .. ..$ plural    : chr "units"
  .. ..$ multiplier: num 1
  .. ..- attr(*, "class")= chr "unitname"
  ..- attr(*, "class")= chr "owin"
 $ n         : int 0
 $ x         : num(0) 
 $ y         : num(0) 
 $ markformat: chr "none"
 - attr(*, "class")= chr "ppp"
 - attr(*, "rejects")=List of 5
  ..$ window    :List of 5
  .. ..$ type  : chr "polygonal"
  .. ..$ xrange: num [1:2] 0 740782
  .. ..$ yrange: num [1:2] 0 5166181
  .. ..$ bdry  :List of 1
  .. .. ..$ :List of 2
  .. .. .. ..$ x: num [1:84] 740778 740777 740777 740776 740773 ...
  .. .. .. ..$ y: num [1:84] 5166156 5166159 5166160 5166163 5166172 ...
  .. ..$ units :List of 3
  .. .. ..$ singular  : chr "unit"
  .. .. ..$ plural    : chr "units"
  .. .. ..$ multiplier: num 1
  .. .. ..- attr(*, "class")= chr "unitname"
  .. ..- attr(*, "class")= chr "owin"
  ..$ n         : int 3628312
  ..$ x         : num [1:3628312] 740721 740721 740721 740721 740721 ...
  ..$ y         : num [1:3628312] 5166181 5166181 5166181 5166181 5166181 ...
  ..$ markformat: chr "none"
  ..- attr(*, "class")= chr "ppp"



(Possible) integer overflow in closepairs() when number of points in pattern equals 1

When running closepairs() on a subset of unknown size I encountered 'Error: cannot allocate vector of size 16.0 Gb'. Apparently, the subset had size 1. I suspect an unsigned integer overflow in the underlying C implementation (e.g. when there is a N - 2 somewhere with N == 1 so that -1 = 2^32 = 4 billion 32-bits floating point numbers = 16 Gb).

A reproducible example:

library("tidyverse")
library("sf")
library("spatstat")

sf <- tibble(x=0, y=0) %>% 
  st_as_sf(coords = c("x", "y"))
ppp <- as.ppp(sf)

closepairs(ppp, rmax = 1, distinct = FALSE)

# Error: cannot allocate vector of size 16.0 Gb
# In addition: Warning message:
#   Estimated number of close pairs exceeds maximum possible integer 

This bug also applies to crosspairs() under similar circumstances. The same error occurs when distinct = TRUE is set. In the case described in the example I would expect a single pair to be returned, in the latter case I would expect a null result.

Edit (relevant information from sessionInfo()):

  • R version: 4.1.2 (2021-11-01)
  • Platform: x86_64-w64-mingw32/x64 (64-bit)
  • spatstat version: spatstat_2.3-0

quadratcount issue with irregular window

As of spatstat.geom version 3.2-2, quadratcount will output count values in the wrong order if one or more cells do not cover an irregular window. For example, the following works as expected:

library(spatstat)
Q <- quadratcount(humberside, 2, 3)
plot(humberside, pch = 3)
plot(Q, add=TRUE, col="blue", cex=1.5, lwd=2)
good_output

However, if one applies a grid that has cells not covered by the irregular window, we get:

Q <- quadratcount(humberside, 5, 3)
plot(humberside, pch = 3)
plot(Q, add=TRUE, col="blue", cex=1.5, lwd=2)
bad_output

This is a result of Q outputting the counts in the wrong order

Q
tile
Tile row 1, col 1 Tile row 1, col 2 Tile row 1, col 3 Tile row 1, col 4 Tile row 2, col 1 Tile row 2, col 2 
                0                 3                 0                 2                 2                 3 
Tile row 2, col 3 Tile row 2, col 4 Tile row 2, col 5 Tile row 3, col 2 Tile row 3, col 3 Tile row 3, col 4 
               14               117                19                 5                35                 0 
Tile row 3, col 5 
                3 

This issue does not manifest itself with spatsat.geom 3.0-3 which outputs the values in the correct order shown here:

tile
Tile row 1, col 1 Tile row 1, col 2 Tile row 1, col 3 Tile row 1, col 4 Tile row 2, col 1 Tile row 2, col 2 
                0                 0                 3                19                 3                 2
Tile row 2, col 3 Tile row 2, col 4 Tile row 2, col 5 Tile row 3, col 2 Tile row 3, col 3 Tile row 3, col 4 
               14                 5                 0                 2               117                35 
Tile row 3, col 5 
                3 

Error in example of `commonGrid()`

> library(spatstat.geom)
Loading required package: spatstat.data
spatstat.geom 2.999-999.004
> example(commonGrid)

cmmnGr> if(require(spatstat.random)) {
cmmnGr+    A <- setcov(square(1))
cmmnGr+    G <- density(runifpoint(42), dimyx=16)
cmmnGr+    H <- commonGrid(A, letterR, G)
cmmnGr+    newR <- as.mask(letterR, xy=H)
cmmnGr+    newG <- as.im(G, W=H)
cmmnGr+ }
Loading required package: spatstat.random
spatstat.random 2.999-999.001
Error in density.default(runifpoint(42), dimyx = 16) : 
  argument 'x' must be numeric
In addition: Warning message:
In density.default(runifpoint(42), dimyx = 16) :
 extra argumentdimyxwill be disregarded 

as.polygonal from mask window fails when mask contains NA values

I ran into this when creating polygonal masks from matrices that had been clipped using raster::mask. It's fixable in client code by avoiding the NAs, but maybe as.polygonal should replace NA values in the mask with FALSE, as done in this reprex?

# Mask with NA values, e.g. from raster::mask
test = structure(c(NA, NA, NA, NA, NA, FALSE, FALSE, NA, NA, NA, FALSE, 
                   FALSE, NA, NA, NA, FALSE, FALSE, FALSE, NA, NA, FALSE, TRUE, 
                   TRUE, NA, NA), .Dim = c(5L, 5L))

test
#>      [,1]  [,2]  [,3]  [,4]  [,5]
#> [1,]   NA FALSE FALSE FALSE FALSE
#> [2,]   NA FALSE FALSE FALSE  TRUE
#> [3,]   NA    NA    NA FALSE  TRUE
#> [4,]   NA    NA    NA    NA    NA
#> [5,]   NA    NA    NA    NA    NA

# Fails
spatstat.geom::as.polygonal(spatstat.geom::owin(mask=test))
#> Error in spatstat.geom::as.polygonal(spatstat.geom::owin(mask = test)): Internal error: length(starts)= 1 , length(finishes)= 0

# Works if NAs are replaced with FALSE
test[is.na(test)] = FALSE
spatstat.geom::as.polygonal(spatstat.geom::owin(mask=test))
#> window: polygonal boundary
#> enclosing rectangle: [3.95, 5.05] x [0.95, 3.05] units

Created on 2021-11-29 by the reprex package (v2.0.1)

Supply dmax argument to nncross.ppp function

Hello,

I appreciate the fast implementation in C of the nncross.ppp function, but unfortunately the call
dmax <- diameter(boundingbox(as.rectangle(X), as.rectangle(Y))) is consuming most of the time when calling this function repeatedly on the same point pattern for different features. If I could precalculate dmax that would really speed up things. Any chance you could add dmax = diameter(boundingbox(as.rectangle(X), as.rectangle(Y))) as default argument to the header so I can override it?

Many thanks,

Stijn

Object 'SG_anydupxy' not found

Hi,
I freshly installed the spatstat package today, but I'm already experiencing an error when trying to create a point pattern:

test <- data.frame(X = c(0,1,2), Y = c(3,2,4))
testppp <- ppp(test$X, test$Y, c(0,5), c(0,5))

This results in the following error:

Error in anyDuplicated.ppp(pp) : object 'SG_anydupxy' not found

It also happens when I use clickppp(). Whenever I search for this issue, it only leads me to the anyDuplicated.ppp function, which indeed contains one instance of SG_anydupxy. Have you got any ideas as to why this is happening?

My R session:

R version 4.1.3 (2022-03-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=Dutch_Netherlands.1252  LC_CTYPE=Dutch_Netherlands.1252    LC_MONETARY=Dutch_Netherlands.1252
[4] LC_NUMERIC=C                       LC_TIME=Dutch_Netherlands.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] spatstat_3.0-2         spatstat.linnet_3.0-3  spatstat.model_3.0-2   rpart_4.1.16          
 [5] spatstat.explore_3.0-5 nlme_3.1-155           spatstat.random_3.0-1  spatstat.geom_3.0-3   
 [9] spatstat.data_3.0-0    stringr_1.4.1          ggmap_3.0.1            ggplot2_3.3.6         
[13] dplyr_1.0.9            data.table_1.14.2     

loaded via a namespace (and not attached):
 [1] tidyselect_1.1.2      purrr_0.3.4           splines_4.1.3         lattice_0.20-45       colorspace_2.0-3     
 [6] vctrs_0.4.1           generics_0.1.2        spatstat.utils_3.0-1  mgcv_1.8-39           utf8_1.2.2           
[11] rlang_1.0.2           pillar_1.7.0          glue_1.6.2            withr_2.5.0           DBI_1.1.2            
[16] sp_1.4-7              jpeg_0.1-9            lifecycle_1.0.1       plyr_1.8.7            munsell_0.5.0        
[21] gtable_0.3.0          RgoogleMaps_1.4.5.3   labeling_0.4.2        fansi_1.0.3           Rcpp_1.0.8.3         
[26] tensor_1.5            scales_1.2.0          abind_1.4-5           farver_2.1.0          deldir_1.0-6         
[31] digest_0.6.29         png_0.1-7             stringi_1.7.6         spatstat.sparse_3.0-0 polyclip_1.10-4      
[36] grid_4.1.3            cli_3.3.0             tools_4.1.3           bitops_1.0-7          magrittr_2.0.3       
[41] goftest_1.2-3         tibble_3.1.7          crayon_1.5.1          tidyr_1.2.1           pkgconfig_2.0.3      
[46] ellipsis_0.3.2        Matrix_1.4-0          assertthat_0.2.1      httr_1.4.4            rstudioapi_0.13      
[51] R6_2.5.1              compiler_4.1.3

`as.data.frame` doesn't work when `nsim > 1`

When using rpoispp I've discovered that as.data.frame doesn't work with nsim > 1. As

> rpoispp(100, nsim = 12) |>
+   as.data.frame()
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE,  : 
  arguments imply differing number of rows: 85, 94, 106, 100, 91, 111, 97, 98, 89, 92

I can get around this, but honestly I think there should be a as.data.frame.ppplist:

as.data.frame.ppplist <- function(x, ...) {
  do.call(what = rbind,
          args = lapply(x, as.data.frame.ppp, ...))
}

Unfortunately, this doesn't get us all the way, as:

> rpoispp(2, nsim = 12) |>
+   as.data.frame()
                        x          y
Simulation 1.1  0.3500342 0.45925195
Simulation 1.2  0.7359299 0.17781784
Simulation 1.3  0.9254328 0.51028685
Simulation 1.4  0.6157233 0.86186033
Simulation 1.5  0.7507317 0.81154081
Simulation 2.1  0.7558588 0.85644016
Simulation 2.2  0.2260337 0.27851179
Simulation 5    0.7813405 0.42246301
Simulation 8    0.5706969 0.86216191
Simulation 9.1  0.1003703 0.62929461
Simulation 9.2  0.3968383 0.08644775
Simulation 10.1 0.7720783 0.32627933
Simulation 10.2 0.6414470 0.99893650
Simulation 11   0.1248797 0.88483252

After the . the index of each point in the simulation set is given only if the simulation yielded more than 1 point...

Error: 'transmat' is not an exported object from 'namespace:spatstat'

Hi Spatstat Team, I saw your email today and am in the process of updating a vignette for a package that will use the updated spatstat hierarchy (note: not changes have been submitted to CRAN yet). I came across an error when converting from a raster object to a pixel image. I am using the maptools::as.im.RasterLayer() function but the same error occurs with the spatstat.geom::as.im() function. I am using spatstat 2.0-0 and spatstat.geom 1.65-6 (see session info at end)

Here is the error:

#> Error: 'transmat' is not an exported object from 'namespace:spatstat'

And here is a reproducible example:

Load libraries

library(raster)
#> Loading required package: sp
library(maptools)
#> Checking rgeos availability: TRUE
library(spatstat)
#> Loading required package: spatstat.data
#> Loading required package: spatstat.geom
#> spatstat.geom 1.65-6
#> 
#> Attaching package: 'spatstat.geom'
#> The following objects are masked from 'package:raster':
#> 
#>     area, rotate, shift
#> Loading required package: spatstat.core
#> Loading required package: nlme
#> 
#> Attaching package: 'nlme'
#> The following object is masked from 'package:raster':
#> 
#>     getData
#> Loading required package: rpart
#> spatstat.core 1.65-6
#> Loading required package: spatstat.linnet
#> 
#> spatstat 2.0-0       (nickname: 'Caution: contains small parts') 
#> For an introduction to spatstat, type 'beginner'

Load raster object

r <- raster(system.file("external/test.grd", package="raster"))
r
#> class      : RasterLayer 
#> dimensions : 115, 80, 9200  (nrow, ncol, ncell)
#> resolution : 40, 40  (x, y)
#> extent     : 178400, 181600, 329400, 334000  (xmin, xmax, ymin, ymax)
#> crs        : +proj=sterea +lat_0=52.1561605555556 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +datum=WGS84 +units=m +no_defs 
#> source     : /Library/Frameworks/R.framework/Versions/4.0/Resources/library/raster/external/test.grd 
#> names      : test 
#> values     : 138.7071, 1736.058  (min, max)
plot(r)

download

Convert to pixel image

maptools::as.im.RasterLayer(r)
#> Error: 'transmat' is not an exported object from 'namespace:spatstat'
spatstat.geom::as.im(r)
#> Error: 'transmat' is not an exported object from 'namespace:spatstat'

And my session info:

sessionInfo()
#> R version 4.0.3 (2020-10-10)
#> Platform: x86_64-apple-darwin17.0 (64-bit)
#> Running under: macOS Catalina 10.15.7
#> 
#> Matrix products: default
#> BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
#> 
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#>  [1] spatstat_2.0-0         spatstat.linnet_1.65-6 spatstat.core_1.65-6  
#>  [4] rpart_4.1-15           nlme_3.1-151           spatstat.geom_1.65-6  
#>  [7] spatstat.data_2.0-0    maptools_1.0-2         raster_3.4-5          
#> [10] sp_1.4-5              
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.6            pillar_1.4.7          compiler_4.0.3       
#>  [4] highr_0.8             tools_4.0.3           goftest_1.2-2        
#>  [7] digest_0.6.27         evaluate_0.14         lifecycle_0.2.0      
#> [10] tibble_3.0.6          lattice_0.20-41       mgcv_1.8-33          
#> [13] pkgconfig_2.0.3       rlang_0.4.10          reprex_1.0.0         
#> [16] Matrix_1.3-2          rgdal_1.5-23          yaml_2.2.1           
#> [19] xfun_0.20             styler_1.3.2          stringr_1.4.0        
#> [22] knitr_1.31            fs_1.5.0              vctrs_0.3.6          
#> [25] spatstat.utils_2.0-0  grid_4.0.3            glue_1.4.2           
#> [28] foreign_0.8-81        rmarkdown_2.6         polyclip_1.10-0.001  
#> [31] purrr_0.3.4           deldir_0.2-9          magrittr_2.0.1       
#> [34] tensor_1.5            splines_4.0.3         backports_1.2.1      
#> [37] codetools_0.2-18      ellipsis_0.3.1        htmltools_0.5.1.1    
#> [40] abind_1.4-5           spatstat.sparse_1.2-1 stringi_1.5.3        
#> [43] crayon_1.4.0

Created on 2021-02-11 by the reprex package (v1.0.0)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.