diff --git a/R/local-moran-bv.R b/R/local-moran-bv.R index 24330422..54646f67 100644 --- a/R/local-moran-bv.R +++ b/R/local-moran-bv.R @@ -6,10 +6,16 @@ local_moran_bv_calc <- function(x, y, listw) { localmoran_bv <- function(x, y, listw, nsim = 199, scale = TRUE, - alternative="two.sided", iseed=1L, no_repeat_in_row=FALSE) { + alternative="two.sided", iseed=1L, no_repeat_in_row=FALSE, + zero.policy=attr(listw, "zero.policy")) { stopifnot(length(x) == length(y)) if(!inherits(listw, "listw")) stop(paste(deparse(substitute(listw)), "is not a listw object")) + if (is.null(zero.policy)) + zero.policy <- get("zeroPolicy", envir = .spdepOptions) + stopifnot(is.logical(zero.policy)) + n <- length(listw$neighbours) + if (n != length(x)) stop("Different numbers of observations") # FIXME is listw assumed to be row-standardized? n <- length(listw$neighbours) stopifnot(n == length(x)) @@ -21,12 +27,28 @@ localmoran_bv <- function(x, y, listw, nsim = 199, scale = TRUE, if (missing(nsim)) stop("nsim must be given") stopifnot(all(!is.na(x))) stopifnot(all(!is.na(y))) + + xx <- mean(x) + ly <- lag.listw(listw, y, zero.policy=zero.policy) + lyy <- mean(ly) + lbs <- c("Low", "High") + quadr <- interaction(cut(x, c(-Inf, xx, Inf), labels=lbs), + cut(ly, c(-Inf, lyy, Inf), labels=lbs), sep="-") + xmed <- median(x) + lymed <- median(ly) + quadr_med <- interaction(cut(x, c(-Inf, xmed, Inf), labels=lbs), + cut(ly, c(-Inf, lymed, Inf), labels=lbs), sep="-") # the variables should be scaled and are by default if (scale) { x <- as.numeric(scale(x)) y <- as.numeric(scale(y)) } + + ly <- lag.listw(listw, y, zero.policy=zero.policy) + quadr_ps <- interaction(cut(x, c(-Inf, 0, Inf), labels=lbs), + cut(ly, c(-Inf, 0, Inf), labels=lbs), sep="-") + cards <- card(listw$neighbours) stopifnot(all(cards > 0L)) # FIXME no zero.policy handling @@ -103,6 +125,8 @@ localmoran_bv <- function(x, y, listw, nsim = 199, scale = TRUE, Prname_sim <- "Pr(folded) Sim" colnames(res) <- c("Ibvi", "E.Ibvi", "Var.Ibvi", "Z.Ibvi", Prname, Prname_rank, Prname_sim) + attr(res, "quadr") <- data.frame(mean=quadr, median=quadr_med, + pysal=quadr_ps) class(res) <- c("localmoran", class(res)) res } diff --git a/R/moran.plot.R b/R/moran.plot.R index 0e087e40..80a1e447 100644 --- a/R/moran.plot.R +++ b/R/moran.plot.R @@ -1,13 +1,14 @@ -# Copyright 2001 by Roger Bivand +# Copyright 2001-24 by Roger Bivand # -moran.plot <- function(x, listw, zero.policy=attr(listw, "zero.policy"), spChk=NULL, +moran.plot <- function(x, listw, y=NULL, zero.policy=attr(listw, "zero.policy"), spChk=NULL, labels=NULL, xlab=NULL, ylab=NULL, quiet=NULL, plot=TRUE, return_df=TRUE, ...) { if (!inherits(listw, "listw")) stop(paste(deparse(substitute(listw)), "is not a listw object")) if (is.null(quiet)) quiet <- !get("verbose", envir = .spdepOptions) stopifnot(is.vector(x)) + if (!is.null(y)) stopifnot(is.vector(y)) stopifnot(is.logical(quiet)) if (is.null(zero.policy)) zero.policy <- get("zeroPolicy", envir = .spdepOptions) @@ -20,14 +21,32 @@ moran.plot <- function(x, listw, zero.policy=attr(listw, "zero.policy"), spChk=N if (is.null(spChk)) spChk <- get.spChkOption() if (spChk && !chkIDs(x, listw)) stop("Check of data and weights ID integrity failed") + if (!is.null(y)) { + yname <- deparse(substitute(y)) + if (!is.numeric(y)) stop(paste(yname, "is not a numeric vector")) + if (any(is.na(y))) stop("NA in Y") + if (n != length(y)) stop("objects of different length") + if (spChk && !chkIDs(y, listw)) + stop("Check of data and weights ID integrity failed") + } labs <- TRUE if (is.logical(labels) && !labels) labs <- FALSE if (is.null(labels) || length(labels) != n) labels <- as.character(attr(listw, "region.id")) - wx <- lag.listw(listw, x, zero.policy=zero.policy) + if (!is.null(y)) { + wx <- lag.listw(listw, y, zero.policy=zero.policy) + } else { + wx <- lag.listw(listw, x, zero.policy=zero.policy) + } if (anyNA(wx)) warning("no-neighbour observation(s) in moran.plot() - use zero.policy=TRUE") if (is.null(xlab)) xlab <- xname - if (is.null(ylab)) ylab <- paste("spatially lagged", xname) + if (is.null(ylab)) { + if (!is.null(y)) { + ylab <- paste("spatially lagged", yname) + } else { + ylab <- paste("spatially lagged", xname) + } + } if (plot) plot(x, wx, xlab=xlab, ylab=ylab, ...) if (plot && zero.policy) { n0 <- wx == 0.0 diff --git a/docs/404.html b/docs/404.html index b8dd0c69..2677b4be 100644 --- a/docs/404.html +++ b/docs/404.html @@ -32,7 +32,7 @@
diff --git a/docs/articles/CO69.html b/docs/articles/CO69.html index 4b2311d9..ec6f6827 100644 --- a/docs/articles/CO69.html +++ b/docs/articles/CO69.html @@ -33,7 +33,7 @@ @@ -127,9 +127,9 @@
library(spdep)
-eire <- as(sf::st_read(system.file("shapes/eire.shp", package="spData")[1]), "Spatial")
+eire <- as(sf::st_read(system.file("shapes/eire.gpkg", package="spData")[1]), "Spatial")
row.names(eire) <- as.character(eire$names)
-proj4string(eire) <- CRS("+proj=utm +zone=30 +ellps=airy +units=km")
+#proj4string(eire) <- CRS("+proj=utm +zone=30 +ellps=airy +units=km")
class(eire)
## [1] "SpatialPolygonsDataFrame"
@@ -565,7 +565,7 @@ Measures of spatial autocorrelation
Prop_stdR <- lapply(vars, function(x) moran.test(eire_ge1[[x]], listw=lw_std, randomisation=TRUE))
})
## user system elapsed
-## 0.145 0.000 0.146
+## 0.115 0.000 0.115
res <- sapply(c("MoranN", "MoranR", "GearyN", "GearyR", "Prop_unstdN", "Prop_unstdR", "Prop_stdN", "Prop_stdR"), function(x) sapply(get(x), "[[", "statistic"))
rownames(res) <- vars
@@ -786,7 +786,7 @@ Simulating measures of s
Prop_stdSad <- lapply(lm_objs, function(x) lm.morantest.sad(x, listw=lw_std))
})
## user system elapsed
-## 0.092 0.000 0.093
+## 0.063 0.000 0.063
res <- sapply(c("MoranSad", "Prop_unstdSad", "Prop_stdSad"), function(x) sapply(get(x), "[[", "statistic"))
rownames(res) <- vars
## user system elapsed
-## 0.107 0.000 0.108
+## 0.081 0.000 0.081
res <- sapply(c("MoranEx", "Prop_unstdEx", "Prop_stdEx"), function(x) sapply(get(x), "[[", "statistic"))
rownames(res) <- vars
## Loading required package: spData
## Loading required package: sf
-## Linking to GEOS 3.12.1, GDAL 3.9.0, PROJ 9.4.0; sf_use_s2() is TRUE
+## Linking to GEOS 3.12.2, GDAL 3.9.0, PROJ 9.4.1; sf_use_s2() is TRUE
-NY8 <- as(sf::st_read(system.file("shapes/NY8_utm18.shp", package="spData")), "Spatial")
## Reading layer `NY8_utm18' from data source
-## `/home/rsb/lib/r_libs/spData/shapes/NY8_utm18.shp' using driver `ESRI Shapefile'
-## Simple feature collection with 281 features and 17 fields
-## Geometry type: POLYGON
+if (packageVersion("spData") >= "2.3.2") {
+ NY8a <- sf::st_read(system.file("shapes/NY8_utm18.gpkg", package="spData"))
+} else {
+ NY8a <- sf::st_read(system.file("shapes/NY8_bna_utm18.gpkg", package="spData"))
+ sf::st_crs(NY8a) <- "EPSG:32618"
+ NY8a$Cases <- NY8a$TRACTCAS
+}
+## Reading layer `sf_bna2_utm18' from data source
+## `/home/rsb/lib/r_libs/spData/shapes/NY8_bna_utm18.gpkg' using driver `GPKG'
+## Simple feature collection with 281 features and 12 fields
+## Geometry type: MULTIPOLYGON
## Dimension: XY
-## Bounding box: xmin: 358241.9 ymin: 4649755 xmax: 480393.1 ymax: 4808545
-## Projected CRS: WGS 84 / UTM zone 18N
-
-NY_nb <- read.gal(system.file("weights/NY_nb.gal", package="spData"), region.id=as.character(as.integer(row.names(NY8))-1L))
## Warning: st_crs<- : replacing crs does not reproject data; use st_transform for
+## that
+
+NY8 <- as(NY8a, "Spatial")
+NY_nb <- read.gal(system.file("weights/NY_nb.gal", package="spData"), region.id=as.character(as.integer(row.names(NY8))-1L))
For the sake of simplicity in showing how to create neighbour
objects, we work on a subset of the map consisting of the census tracts
within Syracuse, although the same principles apply to the full data
set. We retrieve the part of the neighbour list in Syracuse using the
subset
method.
-Syracuse <- NY8[NY8$AREANAME == "Syracuse city",]
-Sy0_nb <- subset(NY_nb, NY8$AREANAME == "Syracuse city")
+
+Syracuse <- NY8[!is.na(NY8$AREANAME) & NY8$AREANAME == "Syracuse city",]
+Sy0_nb <- subset(NY_nb, !is.na(NY8$AREANAME) & NY8$AREANAME == "Syracuse city")
summary(Sy0_nb)
## Neighbour list object:
## Number of regions: 63
@@ -178,12 +187,12 @@ Creating Contiguity Neighbours
+
class(Syracuse)
## [1] "SpatialPolygonsDataFrame"
## attr(,"package")
## [1] "sp"
-
+
## [1] TRUE
@@ -202,11 +211,11 @@ Creating Contiguity Neighbours
+
## [1] FALSE
-
+
oopar <- par(mfrow=c(1,2), mar=c(3,3,1,1)+0.1)
plot(Syracuse, border="grey60")
plot(Sy0_nb, coordinates(Syracuse), add=TRUE, pch=19, cex=0.6)
@@ -217,10 +226,10 @@ Creating Contiguity Neighbours=TRUE, pch=".", cex=0.6, lwd=2)
## Warning in diffnb(Sy0_nb, Sy2_nb, verbose = FALSE): region.id differ; using ids
## of first list
-
+
-
+
par(oopar)
a: Queen-style census tract contiguities, Syracuse; b: Rook-style
contiguity differences shown as thicker lines
@@ -242,7 +251,7 @@ Creating Contiguity Neighbours
+
library(spgrass6)
writeVECT6(Syracuse, "SY0")
contig <- vect2neigh("SY0")
@@ -284,7 +293,7 @@ Creating Graph-Based Neighbours(Avis and Horton
1985). Functions for graph-based neighbours were kindly
contributed by Nicholas Lewin-Koh.
-
+
coords <- coordinates(Syracuse)
IDs <- row.names(as(Syracuse, "data.frame"))
#FIXME library(tripack)
@@ -297,10 +306,10 @@ Creating Graph-Based Neighbours## The following object is masked from 'package:stats':
##
## as.dendrogram
-
+
Sy6_nb <- graph2nb(gabrielneigh(coords), row.names=IDs)
Sy7_nb <- graph2nb(relativeneigh(coords), row.names=IDs)
-
+
oopar <- par(mfrow=c(2,2), mar=c(1,1,1,1)+0.1)
plot(Syracuse, border="grey60")
plot(Sy4_nb, coords, add=TRUE, pch=".")
@@ -317,7 +326,7 @@ Creating Graph-Based Neighboursplot(Sy7_nb, coords, add=TRUE, pch=".")
text(bbox(Syracuse)[1,1], bbox(Syracuse)[2,2], labels="d)", cex=0.8)
-
+
par(oopar)
a: Delauney triangulation neighbours; b: Sphere of influence
neighbours (if available); c: Gabriel graph neighbours; d: Relative
@@ -342,14 +351,14 @@
Creating Graph-Based Neighbours
-
+
nb_l <- list(Triangulation=Sy4_nb, Gabriel=Sy6_nb,
Relative=Sy7_nb)
if (!is.null(Sy5_nb)) nb_l <- c(nb_l, list(SOI=Sy5_nb))
sapply(nb_l, function(x) is.symmetric.nb(x, verbose=FALSE, force=TRUE))
## Triangulation Gabriel Relative SOI
## TRUE FALSE FALSE TRUE
-
+
## Triangulation Gabriel Relative SOI
## 1 1 1 1
@@ -366,7 +375,7 @@ Distance-Based Neighboursnb object by knn2nb()
;
knearneigh()
can also take a longlat=
argument
to handle geographical coordinates.
-
+
Sy8_nb <- knn2nb(knearneigh(coords, k=1), row.names=IDs)
Sy9_nb <- knn2nb(knearneigh(coords, k=2), row.names=IDs)
Sy10_nb <- knn2nb(knearneigh(coords, k=4), row.names=IDs)
@@ -374,11 +383,11 @@ Distance-Based Neighbourssapply(nb_l, function(x) is.symmetric.nb(x, verbose=FALSE, force=TRUE))
## k1 k2 k4
## FALSE FALSE FALSE
-
+
## k1 k2 k4
## 15 1 1
-
+
oopar <- par(mfrow=c(1,3), mar=c(1,1,1,1)+0.1)
plot(Syracuse, border="grey60")
plot(Sy8_nb, coords, add=TRUE, pch=".")
@@ -390,7 +399,7 @@ Distance-Based Neighboursplot(Sy10_nb, coords, add=TRUE, pch=".")
text(bbox(Syracuse)[1,1], bbox(Syracuse)[2,2], labels="c)", cex=0.8)
-
+
par(oopar)
a: \(k=1\) neighbours; b: \(k=2\) neighbours; c: \(k=4\) neighbours
The figure shows the neighbour relationships for \(k= 1, 2, 4\), with many components for
@@ -406,16 +415,16 @@
Distance-Based Neighboursd2 setting the lower and upper distance bounds; it can
also take a longlat
argument to handle geographical
coordinates.
-
+
## Min. 1st Qu. Median Mean 3rd Qu. Max.
-## 395.7 587.3 700.1 760.4 906.1 1544.6
-
+## 395.6 586.9 700.1 760.3 905.9 1544.6
+
max_1nn <- max(dsts)
max_1nn
-## [1] 1544.615
-
+## [1] 1544.635
+
Sy11_nb <- dnearneigh(coords, d1=0, d2=0.75*max_1nn, row.names=IDs)
Sy12_nb <- dnearneigh(coords, d1=0, d2=1*max_1nn, row.names=IDs)
Sy13_nb <- dnearneigh(coords, d1=0, d2=1.5*max_1nn, row.names=IDs)
@@ -423,11 +432,11 @@ Distance-Based Neighbourssapply(nb_l, function(x) is.symmetric.nb(x, verbose=FALSE, force=TRUE))
## d1 d2 d3
## TRUE TRUE TRUE
-
+
## d1 d2 d3
## 4 1 1
-
+
oopar <- par(mfrow=c(1,3), mar=c(1,1,1,1)+0.1)
plot(Syracuse, border="grey60")
plot(Sy11_nb, coords, add=TRUE, pch=".")
@@ -439,7 +448,7 @@ Distance-Based Neighboursplot(Sy13_nb, coords, add=TRUE, pch=".")
text(bbox(Syracuse)[1,1], bbox(Syracuse)[2,2], labels="c)", cex=0.8)
-
+
par(oopar)
a: Neighbours within 1,158m; b: neighbours within 1,545m; c:
neighbours within 2,317m
@@ -451,7 +460,7 @@ Distance-Based Neighbours
-
+
dS <- c(0.75, 1, 1.5)*max_1nn
res <- sapply(nb_l, function(x) table(card(x)))
mx <- max(card(Sy13_nb))
@@ -474,11 +483,11 @@ Distance-Based Neighbours
-
+
dsts0 <- unlist(nbdists(NY_nb, coordinates(NY8)))
summary(dsts0)
-## Min. 1st Qu. Median Mean 3rd Qu. Max.
-## 82.7 1505.0 3378.7 5865.8 8954.3 38438.1
+## Min. 1st Qu. Median Mean 3rd Qu. Max.
+## 82.85 1504.94 3378.60 5896.80 9012.82 41490.76
If the areal entities are approximately regularly spaced, using
distance-based neighbours is not necessarily a problem. Provided that
care is taken to handle the side effects of “weighting” areas out of the
@@ -504,7 +513,7 @@
Higher-Order Neighboursnblag() function takes an existing neighbour list and
returns a list of lists, from first to maxlag=
order
neighbours.
-
+
Sy0_nb_lags <- nblag(Sy0_nb, maxlag=9)
names(Sy0_nb_lags) <- c("first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth")
res <- sapply(Sy0_nb_lags, function(x) table(card(x)))
@@ -543,14 +552,14 @@ Grid Neighbours
-
+
cell2nb(7, 7, type="rook", torus=TRUE)
## Neighbour list object:
## Number of regions: 49
## Number of nonzero links: 196
## Percentage nonzero weights: 8.163265
## Average number of links: 4
-
+
cell2nb(7, 7, type="rook", torus=FALSE)
## Neighbour list object:
## Number of regions: 49
@@ -567,7 +576,7 @@ Grid Neighbours\(63 \times 63\) matrix for Syracuse census
tracts, but demanding for a 3,\(103 \times
3\),103 matrix.
-
+
data(meuse.grid)
coordinates(meuse.grid) <- c("x", "y")
gridded(meuse.grid) <- TRUE
@@ -579,7 +588,7 @@ Grid Neighbours## Number of nonzero links: 12022
## Percentage nonzero weights: 0.1248571
## Average number of links: 3.874315
-
+
##
## 1 2 3 4
diff --git a/docs/articles/nb_files/figure-html/unnamed-chunk-12-1.png b/docs/articles/nb_files/figure-html/unnamed-chunk-12-1.png
index 60bbb886..14c74509 100644
Binary files a/docs/articles/nb_files/figure-html/unnamed-chunk-12-1.png and b/docs/articles/nb_files/figure-html/unnamed-chunk-12-1.png differ
diff --git a/docs/articles/nb_files/figure-html/unnamed-chunk-14-1.png b/docs/articles/nb_files/figure-html/unnamed-chunk-14-1.png
index 8fa2fc39..aa8a77f4 100644
Binary files a/docs/articles/nb_files/figure-html/unnamed-chunk-14-1.png and b/docs/articles/nb_files/figure-html/unnamed-chunk-14-1.png differ
diff --git a/docs/articles/nb_files/figure-html/unnamed-chunk-6-1.png b/docs/articles/nb_files/figure-html/unnamed-chunk-6-1.png
index 3a29d752..192bc2c7 100644
Binary files a/docs/articles/nb_files/figure-html/unnamed-chunk-6-1.png and b/docs/articles/nb_files/figure-html/unnamed-chunk-6-1.png differ
diff --git a/docs/articles/nb_files/figure-html/unnamed-chunk-9-1.png b/docs/articles/nb_files/figure-html/unnamed-chunk-9-1.png
index 8fc6b9ac..33088608 100644
Binary files a/docs/articles/nb_files/figure-html/unnamed-chunk-9-1.png and b/docs/articles/nb_files/figure-html/unnamed-chunk-9-1.png differ
diff --git a/docs/articles/nb_sf.html b/docs/articles/nb_sf.html
index 3e280014..3db4d772 100644
--- a/docs/articles/nb_sf.html
+++ b/docs/articles/nb_sf.html
@@ -33,7 +33,7 @@
@@ -229,9 +229,9 @@ Comparison of sp and sf approaches}
if (dothis) sf_extSoftVersion()
## GEOS GDAL proj.4 GDAL_with_GEOS USE_PROJ_H
-## "3.12.1" "3.9.0" "9.4.0" "true" "true"
+## "3.12.2" "3.9.0" "9.4.1" "true" "true"
## PROJ
-## "9.4.0"
+## "9.4.1"
Let us read the GPKG file with valid geometries in to ‘sf’ and ‘sp’
objects:
@@ -258,7 +258,7 @@ Contiguity neighbours for pol
eps <- sqrt(.Machine$double.eps)
system.time(for(i in 1:reps) NY8_sf_1_nb <- poly2nb(NY8_sf, queen=TRUE, snap=eps))/reps
## user system elapsed
-## 0.1242 0.0056 0.1310
+## 0.0995 0.0042 0.1045
Using spatial indices to check intersection of polygons is much
faster than the legacy method in poly2nb. From spdep
1.1-7, use is made of GEOS through sf to find candidate
@@ -296,24 +296,36 @@
Contiguity neighbours from
boundaries used in ASDAR, but with some invalid geometries as mentioned
earlier:
-NY8_sf_old <- st_read(system.file("shapes/NY8_utm18.shp", package="spData"), quiet=TRUE)
-table(st_is_valid(NY8_sf_old))
+if (packageVersion("spData") >= "2.3.2") {
+ NY8_sf_old <- sf::st_read(system.file("shapes/NY8_utm18.gpkg", package="spData"))
+} else {
+ NY8_sf_old <- sf::st_read(system.file("shapes/NY8_bna_utm18.gpkg", package="spData"))
+ sf::st_crs(NY8_sf_old) <- "EPSG:32618"
+ NY8_sf_old$Cases <- NY8_sf_old$TRACTCAS
+}
+## Reading layer `sf_bna2_utm18' from data source
+## `/home/rsb/lib/r_libs/spData/shapes/NY8_bna_utm18.gpkg' using driver `GPKG'
+## Simple feature collection with 281 features and 12 fields
+## Geometry type: MULTIPOLYGON
+## Dimension: XY
+## Bounding box: xmin: 357628 ymin: 4649538 xmax: 480360.3 ymax: 4808317
+## Projected CRS: UTM Zone 18, Northern Hemisphere
+## Warning: st_crs<- : replacing crs does not reproject data; use st_transform for
+## that
+
+table(st_is_valid(NY8_sf_old))
##
-## FALSE TRUE
-## 5 276
+## TRUE
+## 281
We can see that there are a number of differences between the
neighbour sets derived from the fully valid geometries and the older
partly invalid set:
-
+
try(NY8_sf_old_1_nb <- poly2nb(NY8_sf_old), silent = TRUE)
all.equal(NY8_sf_old_1_nb, NY8_sf_1_nb, check.attributes=FALSE)
-## [1] "Component 57: Numeric: lengths (4, 5) differ"
-## [2] "Component 58: Numeric: lengths (5, 6) differ"
-## [3] "Component 66: Numeric: lengths (7, 11) differ"
-## [4] "Component 73: Numeric: lengths (4, 5) differ"
-## [5] "Component 260: Numeric: lengths (8, 9) differ"
+## [1] TRUE
Using st_make_valid()
to make the geometries valid:
-
+
NY8_sf_old_val <- st_make_valid(NY8_sf_old, dist=0)
table(st_is_valid(NY8_sf_old_val))
##
@@ -321,22 +333,22 @@ Contiguity neighbours from
## 281
we also see that the geometry type of the geometry column
changes:
-
+
class(st_geometry(NY8_sf_old))
-## [1] "sfc_POLYGON" "sfc"
-
+## [1] "sfc_MULTIPOLYGON" "sfc"
+
class(st_geometry(NY8_sf_old_val))
## [1] "sfc_GEOMETRY" "sfc"
and checking the "sfg"
objects, two now have objects of
different topological dimensions.
-
+
table(sapply(st_geometry(NY8_sf_old_val), function(x) class(x)[[2]]))
##
## MULTIPOLYGON POLYGON
-## 3 278
+## 4 277
This can be remedied using st_collection_extract()
to
get the polygon objects:
-
+
NY8_sf_old_val <- st_collection_extract(NY8_sf_old_val, "POLYGON")
table(sapply(st_geometry(NY8_sf_old_val), function(x) class(x)[[2]]))
##
@@ -345,17 +357,13 @@ Contiguity neighbours from
However, in making the geometries valid, we change the geometries, so
the new sets of neighbours still differ from those made with the valid
geometries in the same ways as before imposing validity:
-
+
try(NY8_sf_old_1_nb_val <- poly2nb(NY8_sf_old_val), silent = TRUE)
all.equal(NY8_sf_old_1_nb_val, NY8_sf_1_nb, check.attributes=FALSE)
-## [1] "Component 57: Numeric: lengths (4, 5) differ"
-## [2] "Component 58: Numeric: lengths (5, 6) differ"
-## [3] "Component 66: Numeric: lengths (7, 11) differ"
-## [4] "Component 73: Numeric: lengths (4, 5) differ"
-## [5] "Component 260: Numeric: lengths (8, 9) differ"
+## [1] TRUE
The neighbour sets are the same for the old boundaries with or
without imposing validity:
-
+
all.equal(NY8_sf_old_1_nb_val, NY8_sf_old_1_nb, check.attributes=FALSE)
## [1] TRUE
@@ -372,20 +380,20 @@ Finding points for polygon objectsof_largest_polygon=TRUE argument to
make sure that the centroid is that of the largest polygon id the
observation is made up of more than one external ring:
-
+
NY8_ct_sf <- st_centroid(st_geometry(NY8_sf), of_largest_polygon=TRUE)
or st_point_on_surface()
which guarantees that the point
will fall on the surface of a member polygon:
-
+
NY8_pos_sf <- st_point_on_surface(st_geometry(NY8_sf))
or indeed taking the centre of the largest inscribed circle (the
function returns a radius line segment, so we choose the central point,
not the point on the circle):
-
+
if (unname(sf_extSoftVersion()["GEOS"] >= "3.9.0"))
NY8_cic_sf <- st_cast(st_inscribed_circle(st_geometry(NY8_sf), nQuadSegs=0), "POINT")[(1:(2*nrow(NY8_sf)) %% 2) != 0]
We need to check whether coordinates are planar or not:
-
+
st_is_longlat(NY8_ct_sf)
## [1] FALSE
@@ -394,7 +402,7 @@ Graph-based neighbours
From this, we can check the graph-based neighbours (planar
coordinates only):
-
+
suppressPackageStartupMessages(require(deldir))
NY84_nb <- tri2nb(NY8_ct_sf)
if (require(dbscan, quietly=TRUE)) {
@@ -405,7 +413,7 @@ Graph-based neighbours## The following object is masked from 'package:stats':
##
## as.dendrogram
-
+
NY86_nb <- graph2nb(gabrielneigh(NY8_ct_sf))
NY87_nb <- graph2nb(relativeneigh(NY8_ct_sf))
@@ -416,44 +424,44 @@ K-nearest neighboursdbscan::kNN() in 2D or 3D
building a kd-tree is used:
-
+
system.time(for (i in 1:reps) NY88_nb_sf <- knn2nb(knearneigh(NY8_ct_sf, k=1)))/reps
## user system elapsed
-## 0.0235 0.0018 0.0254
+## 0.0208 0.0015 0.0226
Legacy code may be used omitting the kd-tree:
-
+
system.time(for (i in 1:reps) NY89_nb_sf <- knn2nb(knearneigh(NY8_ct_sf, k=1, use_kd_tree=FALSE)))/reps
## user system elapsed
-## 0.0251 0.0018 0.0270
+## 0.0192 0.0013 0.0207
Distance neighbours
Distance neighbours need a threshold - nbdists
shows the
maximum distance to first nearest neighbour:
-
+
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 82.85 912.85 1801.11 3441.04 4461.26 17033.11
-
+
max_1nn <- max(dsts)
dnearneigh
can also handle Great Circle distances, but
this is not demonstrated here, as the data set used is planar:
-
+
system.time(for (i in 1:reps) NY810_nb <- dnearneigh(NY8_ct_sf, d1=0, d2=0.75*max_1nn))/reps
## user system elapsed
-## 0.0442 0.0024 0.0469
+## 0.0337 0.0013 0.0352
By default, the function uses dbscan::frNN()
to build a
kd-tree in 2D or 3D which is then used to find distance neighbours. For
small n, the argument use_kd_tree=FALSE
may speed up
computation a little by reverting to legacy code not building a kd-tree
first, but in general the differences are so small that the user will
not notice:
-
+
system.time(for (i in 1:reps) NY811_nb <- dnearneigh(NY8_ct_sf, d1=0, d2=0.75*max_1nn, use_kd_tree=FALSE))/reps
## user system elapsed
-## 0.0241 0.0022 0.0265
+## 0.0199 0.0015 0.0215
@@ -464,7 +472,7 @@ Spherical point-based neighbourssf 1.0-0 to use s2 by default has
opened up new opportunities where spatial indexing on the sphere may
help.
-
+
pts_ll <- st_transform(NY8_ct_sf, "OGC:CRS84")
st_is_longlat(pts_ll)
## [1] TRUE
@@ -475,45 +483,45 @@ K-nearest neighbourssf_use_s2() is TRUE
, knearneigh()
will use spatially indexed points and
s2::s2_closest_edges()
(see https://github.com/r-spatial/s2/issues/125#issuecomment-860107442)
-
+
(old_use_s2 <- sf_use_s2())
## [1] TRUE
and performs well with also with larger data sets:
-
+
sf_use_s2(TRUE)
system.time(for (i in 1:reps) pts_ll1_nb <- knn2nb(knearneigh(pts_ll, k=6)))/reps
## user system elapsed
-## 0.0306 0.0000 0.0308
+## 0.0250 0.0001 0.0252
For this smaller data set, the legacy approach without spatial
indexing is adequate, but slows down as the number of observations
increases:
-
+
sf_use_s2(FALSE)
## Spherical geometry (s2) switched off
-
+
system.time(for (i in 1:reps) pts_ll2_nb <- knn2nb(knearneigh(pts_ll, k=6)))/reps
## user system elapsed
-## 0.0234 0.0000 0.0236
+## 0.0199 0.0000 0.0201
The WGS84 ellipsoid Great Circle distances differ a very little from
the s2 spherical distances, yielding output that here
diverges for two tract centroids:
-
+
all.equal(pts_ll1_nb, pts_ll2_nb, check.attributes=FALSE)
## [1] "Component 52: Mean relative difference: 1.466667"
## [2] "Component 124: Mean relative difference: 0.0251046"
-
+
pts_ll1_nb[[52]]
## [1] 15 38 48 49 50 53
-
+
pts_ll2_nb[[52]]
## [1] 37 38 48 49 50 53
-
+
pts_ll1_nb[[124]]
## [1] 117 122 123 125 133 134
-
+
pts_ll2_nb[[124]]
## [1] 116 117 123 125 133 134
-
+
sf_use_s2(old_use_s2)
## Spherical geometry (s2) switched on
@@ -529,9 +537,9 @@ Distance neighbours.
-
+
max_1nn_ll <- max(unlist(nbdists(knn2nb(knearneigh(pts_ll, k=1)), pts_ll)))
-
+
args(dnearneigh)
## function (x, d1, d2, row.names = NULL, longlat = NULL, bounds = c("GE",
## "LE"), use_kd_tree = TRUE, symtest = FALSE, use_s2 = packageVersion("s2") >
@@ -540,57 +548,57 @@ Distance neighbourss2::s2_dwithin_matrix()
is run:
-
+
if (packageVersion("s2") > "1.0.7") {
system.time(for (i in 1:(reps/5)) pts_ll3_nb <- dnearneigh(pts_ll, d1=0,
d2=0.75*max_1nn_ll))/(reps/5)
}
## user system elapsed
-## 0.049 0.000 0.049
+## 0.0415 0.0000 0.0420
Alternatively, spherical distances can be used with
dwithin=FALSE
and s2::s2_closest_edges()
;
although running in similar time, s2::s2_closest_edges()
depends on the additional k=
argument, which, if mis-set,
may miss valid neighbours:
-
+
system.time(for (i in 1:(reps/5)) pts_ll5_nb <- dnearneigh(pts_ll, d1=0, d2=0.75*max_1nn_ll, dwithin=FALSE))/(reps/5)
## user system elapsed
-## 0.0320 0.0000 0.0325
-
+## 0.028 0.000 0.028
+
if (packageVersion("s2") > "1.0.7") all.equal(pts_ll3_nb, pts_ll5_nb, check.attributes=FALSE)
## [1] TRUE
Using s2::s2_closest_edges()
respects
d1 > 0
without requiring a second pass in R, so is
faster than s2::s2_dwithin_matrix()
:
-
+
if (packageVersion("s2") > "1.0.7") {
system.time(for (i in 1:(reps/5)) pts_ll3a_nb <- dnearneigh(pts_ll, d1=5,
d2=0.75*max_1nn_ll, dwithin=FALSE))/(reps/5)
}
## user system elapsed
-## 0.0320 0.0000 0.0325
+## 0.0265 0.0000 0.0270
Using s2::s2_dwithin_matrix()
requires a second pass,
one for the lower bound, another for the upper bound, and a set
difference operation to find neighbours in the distance band:
-
+
if (packageVersion("s2") > "1.0.7") {
system.time(for (i in 1:(reps/5)) pts_ll5a_nb <- dnearneigh(pts_ll, d1=5,
d2=0.75*max_1nn_ll))/(reps/5)
}
## user system elapsed
-## 0.0805 0.0000 0.0810
-
+## 0.069 0.000 0.069
+
if (packageVersion("s2") > "1.0.7") all.equal(pts_ll3a_nb, pts_ll5a_nb, check.attributes=FALSE)
## [1] TRUE
Setting use_s2=FALSE
falls back to the legacy version,
which uses symmetry to reduce time:
-
+
system.time(for (i in 1:reps) pts_ll6_nb <- dnearneigh(pts_ll, d1=0, d2=0.75*max_1nn_ll, use_s2=FALSE))/reps
## user system elapsed
-## 0.0119 0.0000 0.0121
+## 0.0105 0.0000 0.0105
Minor differences may occur between the legacy ellipsoid and
s2 spherical approaches:
-
+
all.equal(pts_ll5_nb, pts_ll6_nb, check.attributes=FALSE)
## [1] "Component 20: Numeric: lengths (6, 5) differ"
## [2] "Component 28: Numeric: lengths (7, 6) differ"
@@ -614,11 +622,11 @@ Distance neighbours## [20] "Component 235: Numeric: lengths (40, 39) differ"
## [21] "Component 237: Numeric: lengths (14, 15) differ"
## [22] "Component 245: Numeric: lengths (16, 15) differ"
-
+
system.time(for (i in 1:reps) pts_ll6a_nb <- dnearneigh(pts_ll, d1=5, d2=0.75*max_1nn_ll, use_s2=FALSE))/reps
## user system elapsed
-## 0.0118 0.0000 0.0119
-
+## 0.0113 0.0000 0.0116
+
if (packageVersion("s2") > "1.0.7") all.equal(pts_ll5a_nb, pts_ll6a_nb, check.attributes=FALSE)
## [1] "Component 20: Numeric: lengths (6, 5) differ"
## [2] "Component 28: Numeric: lengths (7, 6) differ"
@@ -657,7 +665,7 @@ Contiguity neighbours for spherical polygon supports2 spatial indexing
functionality is accessed in finding candidate neighbours in
intersecting geometries.
-
+
NY8_sf_ll <- st_transform(NY8_sf, "OGC:CRS84")
st_is_longlat(NY8_sf_ll)
## [1] TRUE
@@ -665,11 +673,11 @@ Contiguity neighbours for spherical polygon supports2_intersects_matrix(),
but the results are the same, and because spatial indexing is used, this
scales well for larger data sets:
-
+
system.time(for (i in 1:reps) NY8_sf_1_nb_ll <- poly2nb(NY8_sf_ll, queen=TRUE, snap=eps))/reps
## user system elapsed
-## 0.1876 0.0028 0.1915
-
+## 0.1706 0.0029 0.1774
+
all.equal(NY8_sf_1_nb, NY8_sf_1_nb_ll, check.attributes=FALSE)
## [1] TRUE
diff --git a/docs/articles/sids.html b/docs/articles/sids.html
index 0cb702f8..811f1bc6 100644
--- a/docs/articles/sids.html
+++ b/docs/articles/sids.html
@@ -33,7 +33,7 @@
@@ -124,25 +124,27 @@ IntroductionGetting the data into R
We will be using the spdep and
-spreg packages, here version: spdep, version 1.3-4,
-2024-05-31, the sf package and the
+spreg packages, here version: spdep, version 1.3-5,
+2024-06-10, the sf package and the
tmap package. The data from the sources referred to
above is documented in the help page for the nc.sids
data
set in spData. The actual data, included in a shapefile
of the county boundaries for North Carolina were made available in the
maptools package 1. These data are known to be geographical
coordinates (longitude-latitude in decimal degrees) and are assumed to
-use the NAD27 datum.
+use the NAD27 datum. The ESRI Shapefile is deprecated, and was replaced
+here by a GeoPackage, written from reading the original files in
+spData 2.3.1:
library(spdep)
-nc <- st_read(system.file("shapes/sids.shp", package="spData")[1], quiet=TRUE)
-st_crs(nc) <- "+proj=longlat +datum=NAD27"
+nc <- st_read(system.file("shapes/sids.gpkg", package="spData")[1], quiet=TRUE)
+#st_crs(nc) <- "EPSG:4267"
row.names(nc) <- as.character(nc$FIPSNO)
-The shapefile format presupposes that you have three files with
+
The shapefile format presupposed that you had three files with
extensions .shp
, .shx
, and .dbf
,
where the first contains the geometry data, the second the spatial
-index, and the third the attribute data. They are required to have the
-same name apart from the extension, and are read here using
+index, and the third the attribute data. They were required to have the
+same name apart from the extension, and were read here using
sf::st_read()
into the sf
object
nc
; the class is defined in sf. The
centroids of the largest polygon in each county are available using the
@@ -150,7 +152,7 @@
Getting the data into Rsfc POINT object, and can be used to place labels after
the extraction of the coordinate matrix:
-sf_use_s2(FALSE)
+sf_use_s2(TRUE)
plot(st_geometry(nc), axes=TRUE)
text(st_coordinates(st_centroid(st_geometry(nc), of_largest_polygon=TRUE)), label=nc$FIPSNO, cex=0.5)
@@ -163,7 +165,7 @@ Getting the data into R## [1] "CNTY_ID" "AREA" "PERIMETER" "CNTY_" "NAME" "FIPS"
## [7] "FIPSNO" "CRESS_ID" "BIR74" "SID74" "NWBIR74" "BIR79"
## [13] "SID79" "NWBIR79" "east" "north" "x" "y"
-## [19] "lon" "lat" "L_id" "M_id" "geometry"
+## [19] "lon" "lat" "L_id" "M_id" "geom"
summary(nc)
## CNTY_ID AREA PERIMETER CNTY_
@@ -201,9 +203,9 @@ Getting the data into R## Mean : 91.46 Mean :3953 Mean :-79.51 Mean :35.62
## 3rd Qu.: 240.03 3rd Qu.:4000 3rd Qu.:-77.87 3rd Qu.:36.05
## Max. : 439.65 Max. :4060 Max. :-75.67 Max. :36.52
-## L_id M_id geometry
+## L_id M_id geom
## Min. :1.00 Min. :1.00 MULTIPOLYGON :100
-## 1st Qu.:1.00 1st Qu.:2.00 epsg:NA : 0
+## 1st Qu.:1.00 1st Qu.:2.00 epsg:4267 : 0
## Median :2.00 Median :3.00 +proj=long...: 0
## Mean :2.12 Mean :2.67
## 3rd Qu.:3.00 3rd Qu.:3.25
diff --git a/docs/articles/sids_files/figure-html/plot-CC89.nb-1.png b/docs/articles/sids_files/figure-html/plot-CC89.nb-1.png
index bb8e0e7b..6ed3fbbd 100644
Binary files a/docs/articles/sids_files/figure-html/plot-CC89.nb-1.png and b/docs/articles/sids_files/figure-html/plot-CC89.nb-1.png differ
diff --git a/docs/articles/sids_files/figure-html/unnamed-chunk-25-1.png b/docs/articles/sids_files/figure-html/unnamed-chunk-25-1.png
index fc96e71e..198b8ebb 100644
Binary files a/docs/articles/sids_files/figure-html/unnamed-chunk-25-1.png and b/docs/articles/sids_files/figure-html/unnamed-chunk-25-1.png differ
diff --git a/docs/articles/sids_files/figure-html/unnamed-chunk-3-1.png b/docs/articles/sids_files/figure-html/unnamed-chunk-3-1.png
index 74ac5834..d64029b7 100644
Binary files a/docs/articles/sids_files/figure-html/unnamed-chunk-3-1.png and b/docs/articles/sids_files/figure-html/unnamed-chunk-3-1.png differ
diff --git a/docs/authors.html b/docs/authors.html
index 0132cb5b..af969273 100644
--- a/docs/authors.html
+++ b/docs/authors.html
@@ -17,7 +17,7 @@
diff --git a/docs/index.html b/docs/index.html
index 48ec1a70..654e3caf 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -33,7 +33,7 @@
diff --git a/docs/news/index.html b/docs/news/index.html
index be21450c..631abf09 100644
--- a/docs/news/index.html
+++ b/docs/news/index.html
@@ -17,7 +17,7 @@
@@ -67,7 +67,13 @@ Changelog
+
+Version 1.3-4 (2024-05-31)2024-05-31
add scale
argument to geary.test
, geary.mc
and geary
#151, and appropriate tests
Introduce error in knearneigh
for k
less than the largest count of identical points; if encountered, increase k
remove spurious warning in knearneigh
for longlat geometries
diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml
index 7d0601ca..9a517958 100644
--- a/docs/pkgdown.yml
+++ b/docs/pkgdown.yml
@@ -6,5 +6,5 @@ articles:
nb_sf: nb_sf.html
nb: nb.html
sids: sids.html
-last_built: 2024-05-31T15:04Z
+last_built: 2024-06-10T12:01Z
diff --git a/docs/reference/COL.OLD.html b/docs/reference/COL.OLD.html
index ed679e9e..1e6e6da6 100644
--- a/docs/reference/COL.OLD.html
+++ b/docs/reference/COL.OLD.html
@@ -22,7 +22,7 @@
diff --git a/docs/reference/EBImoran.mc.html b/docs/reference/EBImoran.mc.html
index 53890358..d7feb469 100644
--- a/docs/reference/EBImoran.mc.html
+++ b/docs/reference/EBImoran.mc.html
@@ -17,7 +17,7 @@
@@ -169,7 +169,7 @@ See also
Examples
- nc.sids <- st_read(system.file("shapes/sids.shp", package="spData")[1], quiet=TRUE)
+ nc.sids <- st_read(system.file("shapes/sids.gpkg", package="spData")[1], quiet=TRUE)
rn <- as.character(nc.sids$FIPS)
ncCC89_nb <- read.gal(system.file("weights/ncCC89.gal", package="spData")[1],
region.id=rn)
diff --git a/docs/reference/EBest.html b/docs/reference/EBest.html
index 052ff471..81c05313 100644
--- a/docs/reference/EBest.html
+++ b/docs/reference/EBest.html
@@ -17,7 +17,7 @@
@@ -126,7 +126,7 @@ See also
Examples
- auckland <- st_read(system.file("shapes/auckland.shp", package="spData")[1], quiet=TRUE)
+ auckland <- st_read(system.file("shapes/auckland.gpkg", package="spData")[1], quiet=TRUE)
res <- EBest(auckland$M77_85, 9*auckland$Und5_81)
attr(res, "parameters")
#> $a
diff --git a/docs/reference/EBlocal.html b/docs/reference/EBlocal.html
index 01b47a34..ee748075 100644
--- a/docs/reference/EBlocal.html
+++ b/docs/reference/EBlocal.html
@@ -17,7 +17,7 @@
@@ -135,7 +135,7 @@ See also
Examples
- auckland <- st_read(system.file("shapes/auckland.shp", package="spData")[1], quiet=TRUE)
+ auckland <- st_read(system.file("shapes/auckland.gpkg", package="spData")[1], quiet=TRUE)
auckland.nb <- poly2nb(auckland)
res <- EBlocal(auckland$M77_85, 9*auckland$Und5_81, auckland.nb)
auckland$est000 <- res$est*1000
diff --git a/docs/reference/LOSH.cs.html b/docs/reference/LOSH.cs.html
index 66ec1b42..f15397fc 100644
--- a/docs/reference/LOSH.cs.html
+++ b/docs/reference/LOSH.cs.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/LOSH.html b/docs/reference/LOSH.html
index c28fa7f6..6a9df4ad 100644
--- a/docs/reference/LOSH.html
+++ b/docs/reference/LOSH.html
@@ -19,7 +19,7 @@
diff --git a/docs/reference/LOSH.mc.html b/docs/reference/LOSH.mc.html
index 85d4d746..2b3311f0 100644
--- a/docs/reference/LOSH.mc.html
+++ b/docs/reference/LOSH.mc.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/SD.RStests.html b/docs/reference/SD.RStests.html
index 82d405fa..1c5d33a1 100644
--- a/docs/reference/SD.RStests.html
+++ b/docs/reference/SD.RStests.html
@@ -17,7 +17,7 @@
@@ -137,14 +137,14 @@ See also
Examples
- columbus <- sf::st_read(system.file("shapes/columbus.shp", package="spData")[1])
+ columbus <- sf::st_read(system.file("shapes/columbus.gpkg", package="spData")[1])
#> Reading layer `columbus' from data source
-#> `/home/rsb/lib/r_libs/spData/shapes/columbus.shp' using driver `ESRI Shapefile'
+#> `/home/rsb/lib/r_libs/spData/shapes/columbus.gpkg' using driver `GPKG'
#> Simple feature collection with 49 features and 20 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: 5.874907 ymin: 10.78863 xmax: 11.28742 ymax: 14.74245
-#> CRS: NA
+#> Projected CRS: Undefined Cartesian SRS with unknown unit
col.gal.nb <- read.gal(system.file("weights/columbus.gal", package="spData")[1])
col.listw <- nb2listw(col.gal.nb, style="W")
lm_obj <- lm(CRIME ~ INC + HOVAL, data=columbus)
diff --git a/docs/reference/aggregate.nb.html b/docs/reference/aggregate.nb.html
index 23d61dc6..157331fe 100644
--- a/docs/reference/aggregate.nb.html
+++ b/docs/reference/aggregate.nb.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/airdist.html b/docs/reference/airdist.html
index 48bc6221..0e8bc056 100644
--- a/docs/reference/airdist.html
+++ b/docs/reference/airdist.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/autocov_dist.html b/docs/reference/autocov_dist.html
index 7c4169da..36155a15 100644
--- a/docs/reference/autocov_dist.html
+++ b/docs/reference/autocov_dist.html
@@ -17,7 +17,7 @@
@@ -128,7 +128,7 @@ See also
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
#xy <- cbind(columbus$X, columbus$Y)
xy <- st_coordinates(st_centroid(st_geometry(columbus),
of_largest_polygon=TRUE))
diff --git a/docs/reference/bhicv.html b/docs/reference/bhicv.html
index cd800821..955116e1 100644
--- a/docs/reference/bhicv.html
+++ b/docs/reference/bhicv.html
@@ -18,7 +18,7 @@
@@ -102,16 +102,16 @@ Format
Examples
- bh <- st_read(system.file("etc/shapes/bhicv.shp",
+ bh <- st_read(system.file("etc/shapes/bhicv.gpkg",
package="spdep")[1])
#> Reading layer `bhicv' from data source
-#> `/tmp/RtmpJUukWt/temp_libpathb48a37d011044/spdep/etc/shapes/bhicv.shp'
-#> using driver `ESRI Shapefile'
+#> `/tmp/Rtmpg4Rdk8/temp_libpatheae6955d99354/spdep/etc/shapes/bhicv.gpkg'
+#> using driver `GPKG'
#> Simple feature collection with 98 features and 8 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: -45.02175 ymin: -20.93007 xmax: -42.50321 ymax: -18.08342
-#> CRS: NA
+#> Geodetic CRS: Corrego Alegre 1970-72
diff --git a/docs/reference/card.html b/docs/reference/card.html
index cf885023..e4ac73e0 100644
--- a/docs/reference/card.html
+++ b/docs/reference/card.html
@@ -18,7 +18,7 @@
diff --git a/docs/reference/cell2nb.html b/docs/reference/cell2nb.html
index 9b34173a..d63ed14d 100644
--- a/docs/reference/cell2nb.html
+++ b/docs/reference/cell2nb.html
@@ -21,7 +21,7 @@
diff --git a/docs/reference/choynowski.html b/docs/reference/choynowski.html
index 75ab341d..095d74a7 100644
--- a/docs/reference/choynowski.html
+++ b/docs/reference/choynowski.html
@@ -17,7 +17,7 @@
@@ -124,7 +124,7 @@ See also
Examples
- auckland <- st_read(system.file("shapes/auckland.shp", package="spData")[1], quiet=TRUE)
+ auckland <- st_read(system.file("shapes/auckland.gpkg", package="spData")[1], quiet=TRUE)
auckland.nb <- poly2nb(auckland)
res <- choynowski(auckland$M77_85, 9*auckland$Und5_81)
resl <- choynowski(auckland$M77_85, 9*auckland$Und5_81, legacy=TRUE)
diff --git a/docs/reference/columbus.html b/docs/reference/columbus.html
index 10c983c6..defb0735 100644
--- a/docs/reference/columbus.html
+++ b/docs/reference/columbus.html
@@ -17,7 +17,7 @@
@@ -78,7 +78,7 @@ Columbus OH spatial analysis data set
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
col.gal.nb <- read.gal(system.file("weights/columbus.gal", package="spData")[1])
diff --git a/docs/reference/compon.html b/docs/reference/compon.html
index cc92aab4..552112ef 100644
--- a/docs/reference/compon.html
+++ b/docs/reference/compon.html
@@ -17,7 +17,7 @@
@@ -105,7 +105,7 @@ See also
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
col.gal.nb <- read.gal(system.file("weights/columbus.gal", package="spData")[1])
coords <- st_coordinates(st_centroid(st_geometry(columbus)))
plot(col.gal.nb, coords, col="grey")
diff --git a/docs/reference/diffnb.html b/docs/reference/diffnb.html
index af74e426..03dfd829 100644
--- a/docs/reference/diffnb.html
+++ b/docs/reference/diffnb.html
@@ -17,7 +17,7 @@
@@ -102,7 +102,7 @@ Author
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
coords <- st_centroid(st_geometry(columbus), of_largest_polygon=TRUE)
rn <- row.names(columbus)
knn1 <- knearneigh(coords, 1)
diff --git a/docs/reference/dnearneigh.html b/docs/reference/dnearneigh.html
index b871bbd8..d0f050aa 100644
--- a/docs/reference/dnearneigh.html
+++ b/docs/reference/dnearneigh.html
@@ -17,7 +17,7 @@
@@ -131,7 +131,7 @@ See also
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
coords <- st_centroid(st_geometry(columbus), of_largest_polygon=TRUE)
rn <- row.names(columbus)
k1 <- knn2nb(knearneigh(coords))
@@ -163,7 +163,7 @@ Examples
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: 6.221943 ymin: 11.01003 xmax: 10.95359 ymax: 14.36908
-#> CRS: NA
+#> Projected CRS: Undefined Cartesian SRS with unknown unit
#> First 5 geometries:
#> POINT (8.827218 14.36908)
#> POINT (8.332658 14.03162)
@@ -239,13 +239,13 @@ Examples
gck1b <- knn2nb(knearneigh(xy1, k=1))
system.time(o <- nbdists(gck1b, xy1))
#> user system elapsed
-#> 0.011 0.000 0.011
+#> 0.009 0.000 0.009
(all.linked <- max(unlist(o)))
#> [1] 522.4464
# use s2 brute-force dwithin_matrix approach for s2 <= 1.0.7
system.time(gc.nb.dwithin <- dnearneigh(xy1, 0, all.linked, use_s2=TRUE, dwithin=TRUE))
#> user system elapsed
-#> 0.011 0.000 0.011
+#> 0.01 0.00 0.01
summary(gc.nb, xy1, scale=0.5)
#> Neighbour list object:
#> Number of regions: 48
@@ -266,12 +266,12 @@ Examples
(system.time(gc.nb.closest <- dnearneigh(xy1, 0, all.linked, dwithin=FALSE)))
}
#> user system elapsed
-#> 0.009 0.000 0.010
+#> 0.007 0.000 0.007
if (packageVersion("s2") > "1.0.7") {
system.time(gc.nb.dwithin <- dnearneigh(xy1, 0, all.linked, use_s2=TRUE, dwithin=TRUE))
}
#> user system elapsed
-#> 0.012 0.000 0.013
+#> 0.009 0.000 0.010
if (packageVersion("s2") > "1.0.7") {
summary(gc.nb.dwithin, xy1, scale=0.5)
}
@@ -313,7 +313,7 @@ Examples
# use legacy symmetric brute-force approach
system.time(gc.nb.legacy <- dnearneigh(xy1, 0, all.linked, use_s2=FALSE))
#> user system elapsed
-#> 0.004 0.000 0.005
+#> 0.003 0.000 0.003
summary(gc.nb, xy1, scale=0.5)
#> Neighbour list object:
#> Number of regions: 48
diff --git a/docs/reference/droplinks.html b/docs/reference/droplinks.html
index f7e0e0dd..c68f270e 100644
--- a/docs/reference/droplinks.html
+++ b/docs/reference/droplinks.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/edit.nb.html b/docs/reference/edit.nb.html
index 47aadfe4..0268443c 100644
--- a/docs/reference/edit.nb.html
+++ b/docs/reference/edit.nb.html
@@ -22,7 +22,7 @@
@@ -122,7 +122,7 @@ See also
Examples
# \dontrun{
-columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
class(columbus)
#> [1] "sf" "data.frame"
if (FALSE) nnb1 <- edit.nb(col.gal.nb, polys=as(columbus, "Spatial"))
diff --git a/docs/reference/eire.html b/docs/reference/eire.html
index dff7408b..b2e3ad1c 100644
--- a/docs/reference/eire.html
+++ b/docs/reference/eire.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/geary.html b/docs/reference/geary.html
index 9f19ecb7..8602baac 100644
--- a/docs/reference/geary.html
+++ b/docs/reference/geary.html
@@ -22,7 +22,7 @@
diff --git a/docs/reference/geary.mc.html b/docs/reference/geary.mc.html
index 9cb232c2..130c841e 100644
--- a/docs/reference/geary.mc.html
+++ b/docs/reference/geary.mc.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/geary.test.html b/docs/reference/geary.test.html
index 5f7b964c..4ed31399 100644
--- a/docs/reference/geary.test.html
+++ b/docs/reference/geary.test.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/globalG.test.html b/docs/reference/globalG.test.html
index bda84b6b..d1072482 100644
--- a/docs/reference/globalG.test.html
+++ b/docs/reference/globalG.test.html
@@ -17,7 +17,7 @@
@@ -150,7 +150,7 @@ See also
Examples
- nc.sids <- st_read(system.file("shapes/sids.shp", package="spData")[1], quiet=TRUE)
+ nc.sids <- st_read(system.file("shapes/sids.gpkg", package="spData")[1], quiet=TRUE)
sidsrate79 <- (1000*nc.sids$SID79)/nc.sids$BIR79
dists <- c(10, 20, 30, 33, 40, 50, 60, 70, 80, 90, 100)
ndists <- length(dists)
diff --git a/docs/reference/graphneigh.html b/docs/reference/graphneigh.html
index 05ad31f2..6febf4bd 100644
--- a/docs/reference/graphneigh.html
+++ b/docs/reference/graphneigh.html
@@ -20,7 +20,7 @@
@@ -206,7 +206,7 @@ See also
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
sf_obj <- st_centroid(st_geometry(columbus), of_largest_polygon)
sp_obj <- as(sf_obj, "Spatial")
coords <- st_coordinates(sf_obj)
diff --git a/docs/reference/grid2nb.html b/docs/reference/grid2nb.html
index 38ea505a..5d330889 100644
--- a/docs/reference/grid2nb.html
+++ b/docs/reference/grid2nb.html
@@ -18,7 +18,7 @@
diff --git a/docs/reference/hotspotmap.html b/docs/reference/hotspotmap.html
index 69a558f9..98c7a52a 100644
--- a/docs/reference/hotspotmap.html
+++ b/docs/reference/hotspotmap.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/include.self.html b/docs/reference/include.self.html
index 1bb44e1c..08212722 100644
--- a/docs/reference/include.self.html
+++ b/docs/reference/include.self.html
@@ -17,7 +17,7 @@
@@ -99,7 +99,7 @@ See also
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
col.gal.nb <- read.gal(system.file("weights/columbus.gal", package="spData")[1])
coords <- st_coordinates(st_centroid(columbus))
#> Warning: st_centroid assumes attributes are constant over geometries
diff --git a/docs/reference/index.html b/docs/reference/index.html
index 0d4a8828..62917baa 100644
--- a/docs/reference/index.html
+++ b/docs/reference/index.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/joincount.mc.html b/docs/reference/joincount.mc.html
index b2e2e770..98662a3c 100644
--- a/docs/reference/joincount.mc.html
+++ b/docs/reference/joincount.mc.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/joincount.multi.html b/docs/reference/joincount.multi.html
index 5f199133..6e106217 100644
--- a/docs/reference/joincount.multi.html
+++ b/docs/reference/joincount.multi.html
@@ -17,7 +17,7 @@
@@ -127,7 +127,7 @@ See also
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
HICRIME <- cut(columbus$CRIME, breaks=c(0,35,80), labels=c("low","high"))
(nb <- poly2nb(columbus))
#> Neighbour list object:
diff --git a/docs/reference/joincount.test.html b/docs/reference/joincount.test.html
index 2f9e4847..371b4e68 100644
--- a/docs/reference/joincount.test.html
+++ b/docs/reference/joincount.test.html
@@ -23,7 +23,7 @@
@@ -357,7 +357,7 @@ Examples
#> Same colour statistic Expectation Variance
#> 40.500000 23.000000 6.762918
#>
-columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
HICRIME <- cut(columbus$CRIME, breaks=c(0,35,80), labels=c("low","high"))
(nb <- poly2nb(columbus))
#> Neighbour list object:
diff --git a/docs/reference/knearneigh.html b/docs/reference/knearneigh.html
index 03cddd63..7eb36308 100644
--- a/docs/reference/knearneigh.html
+++ b/docs/reference/knearneigh.html
@@ -17,7 +17,7 @@
@@ -127,7 +127,7 @@ See also
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
coords <- st_centroid(st_geometry(columbus), of_largest_polygon=TRUE)
col.knn <- knearneigh(coords, k=4)
plot(st_geometry(columbus), border="grey")
@@ -191,7 +191,7 @@ Examples
sf_use_s2(TRUE)
system.time(gck4a.nb <- knn2nb(knearneigh(xy1, k=4)))
#> user system elapsed
-#> 0.014 0.000 0.013
+#> 0.010 0.000 0.009
summary(gck4a.nb, xy1, scale=0.5)
#> Neighbour list object:
#> Number of regions: 48
@@ -211,7 +211,7 @@ Examples
#> Spherical geometry (s2) switched off
system.time(gck4a.nb <- knn2nb(knearneigh(xy1, k=4)))
#> user system elapsed
-#> 0.008 0.000 0.007
+#> 0.005 0.000 0.005
summary(gck4a.nb, xy1, scale=0.5)
#> Neighbour list object:
#> Number of regions: 48
diff --git a/docs/reference/knn2nb.html b/docs/reference/knn2nb.html
index 99bcfefe..277aea02 100644
--- a/docs/reference/knn2nb.html
+++ b/docs/reference/knn2nb.html
@@ -19,7 +19,7 @@
@@ -108,7 +108,7 @@ See also
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
coords <- st_coordinates(st_centroid(columbus))
#> Warning: st_centroid assumes attributes are constant over geometries
col.knn <- knearneigh(coords, k=4)
diff --git a/docs/reference/lag.listw.html b/docs/reference/lag.listw.html
index 1280c9f7..483e41af 100644
--- a/docs/reference/lag.listw.html
+++ b/docs/reference/lag.listw.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/lee.html b/docs/reference/lee.html
index 50983ef6..5c49af99 100644
--- a/docs/reference/lee.html
+++ b/docs/reference/lee.html
@@ -21,7 +21,7 @@
diff --git a/docs/reference/lee.mc.html b/docs/reference/lee.mc.html
index 25bc45da..c48be74d 100644
--- a/docs/reference/lee.mc.html
+++ b/docs/reference/lee.mc.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/lee.test.html b/docs/reference/lee.test.html
index 8c639171..b83698c6 100644
--- a/docs/reference/lee.test.html
+++ b/docs/reference/lee.test.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/listw2sn.html b/docs/reference/listw2sn.html
index ef877bd7..d488b536 100644
--- a/docs/reference/listw2sn.html
+++ b/docs/reference/listw2sn.html
@@ -19,7 +19,7 @@
@@ -127,7 +127,7 @@ See also
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
col.gal.nb <- read.gal(system.file("weights/columbus.gal", package="spData")[1])
col.listw <- nb2listw(col.gal.nb)
col.listw$neighbours[[1]]
diff --git a/docs/reference/lm.RStests.html b/docs/reference/lm.RStests.html
index 595b3262..6795d455 100644
--- a/docs/reference/lm.RStests.html
+++ b/docs/reference/lm.RStests.html
@@ -24,7 +24,7 @@
diff --git a/docs/reference/lm.morantest.exact.html b/docs/reference/lm.morantest.exact.html
index fd9ca056..8096e16e 100644
--- a/docs/reference/lm.morantest.exact.html
+++ b/docs/reference/lm.morantest.exact.html
@@ -17,7 +17,7 @@
@@ -179,16 +179,17 @@ See also
Examples
- eire <- st_read(system.file("shapes/eire.shp", package="spData")[1])
+ eire <- st_read(system.file("shapes/eire.gpkg", package="spData")[1])
#> Reading layer `eire' from data source
-#> `/home/rsb/lib/r_libs/spData/shapes/eire.shp' using driver `ESRI Shapefile'
+#> `/home/rsb/lib/r_libs/spData/shapes/eire.gpkg' using driver `GPKG'
#> Simple feature collection with 26 features and 10 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: -4.12 ymin: 5768 xmax: 300.82 ymax: 6119.25
-#> CRS: NA
+#> Projected CRS: Undefined Cartesian SRS with unknown unit
row.names(eire) <- as.character(eire$names)
st_crs(eire) <- "+proj=utm +zone=30 +ellps=airy +units=km"
+#> Warning: st_crs<- : replacing crs does not reproject data; use st_transform for that
eire.nb <- poly2nb(eire)
e.lm <- lm(OWNCONS ~ ROADACC, data=eire)
lm.morantest(e.lm, nb2listw(eire.nb))
diff --git a/docs/reference/lm.morantest.html b/docs/reference/lm.morantest.html
index d5920816..3ea055c9 100644
--- a/docs/reference/lm.morantest.html
+++ b/docs/reference/lm.morantest.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/lm.morantest.sad.html b/docs/reference/lm.morantest.sad.html
index 27f6f791..090c7b07 100644
--- a/docs/reference/lm.morantest.sad.html
+++ b/docs/reference/lm.morantest.sad.html
@@ -18,7 +18,7 @@
@@ -200,16 +200,17 @@ See also
Examples
- eire <- st_read(system.file("shapes/eire.shp", package="spData")[1])
+ eire <- st_read(system.file("shapes/eire.gpkg", package="spData")[1])
#> Reading layer `eire' from data source
-#> `/home/rsb/lib/r_libs/spData/shapes/eire.shp' using driver `ESRI Shapefile'
+#> `/home/rsb/lib/r_libs/spData/shapes/eire.gpkg' using driver `GPKG'
#> Simple feature collection with 26 features and 10 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: -4.12 ymin: 5768 xmax: 300.82 ymax: 6119.25
-#> CRS: NA
+#> Projected CRS: Undefined Cartesian SRS with unknown unit
row.names(eire) <- as.character(eire$names)
st_crs(eire) <- "+proj=utm +zone=30 +ellps=airy +units=km"
+#> Warning: st_crs<- : replacing crs does not reproject data; use st_transform for that
eire.nb <- poly2nb(eire)
e.lm <- lm(OWNCONS ~ ROADACC, data=eire)
lm.morantest(e.lm, nb2listw(eire.nb))
diff --git a/docs/reference/localC.html b/docs/reference/localC.html
index 37455e09..031404bf 100644
--- a/docs/reference/localC.html
+++ b/docs/reference/localC.html
@@ -18,7 +18,7 @@
@@ -359,7 +359,7 @@ Examples
alternative="two.sided"))
}
#> user system elapsed
-#> 0.466 0.009 0.478
+#> 0.348 0.005 0.354
if (run) {
if (require(parallel, quietly=TRUE)) {
ncpus <- max(2L, detectCores(logical=FALSE), na.rm = TRUE)-1L
@@ -505,7 +505,7 @@ Examples
nsim=9999, alternative="two.sided"))
}
#> user system elapsed
-#> 1.273 0.003 1.290
+#> 0.596 0.000 0.599
if (run) {
all.equal(lisa_values(lmc_vars), c(lmc_vars_spdep))
}
diff --git a/docs/reference/localG.html b/docs/reference/localG.html
index d3555a14..f4eb347f 100644
--- a/docs/reference/localG.html
+++ b/docs/reference/localG.html
@@ -23,7 +23,7 @@
diff --git a/docs/reference/localGS.html b/docs/reference/localGS.html
index 481f7a22..ac92249f 100644
--- a/docs/reference/localGS.html
+++ b/docs/reference/localGS.html
@@ -20,7 +20,7 @@
@@ -131,9 +131,9 @@ See also
Examples
# \donttest{
-boston.tr <- sf::st_read(system.file("shapes/boston_tracts.shp", package="spData")[1])
+boston.tr <- sf::st_read(system.file("shapes/boston_tracts.gpkg", package="spData")[1])
#> Reading layer `boston_tracts' from data source
-#> `/home/rsb/lib/r_libs/spData/shapes/boston_tracts.shp' using driver `ESRI Shapefile'
+#> `/home/rsb/lib/r_libs/spData/shapes/boston_tracts.gpkg' using driver `GPKG'
#> Simple feature collection with 506 features and 36 fields
#> Geometry type: POLYGON
#> Dimension: XY
diff --git a/docs/reference/local_joincount_bv.html b/docs/reference/local_joincount_bv.html
index c325b1ec..a994fb90 100644
--- a/docs/reference/local_joincount_bv.html
+++ b/docs/reference/local_joincount_bv.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/local_joincount_uni.html b/docs/reference/local_joincount_uni.html
index c38469d9..9b03b1fe 100644
--- a/docs/reference/local_joincount_uni.html
+++ b/docs/reference/local_joincount_uni.html
@@ -18,7 +18,7 @@
diff --git a/docs/reference/localmoran.exact.html b/docs/reference/localmoran.exact.html
index 6dafa1de..945966d2 100644
--- a/docs/reference/localmoran.exact.html
+++ b/docs/reference/localmoran.exact.html
@@ -17,7 +17,7 @@
@@ -208,16 +208,17 @@ See also
Examples
- eire <- st_read(system.file("shapes/eire.shp", package="spData")[1])
+ eire <- st_read(system.file("shapes/eire.gpkg", package="spData")[1])
#> Reading layer `eire' from data source
-#> `/home/rsb/lib/r_libs/spData/shapes/eire.shp' using driver `ESRI Shapefile'
+#> `/home/rsb/lib/r_libs/spData/shapes/eire.gpkg' using driver `GPKG'
#> Simple feature collection with 26 features and 10 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: -4.12 ymin: 5768 xmax: 300.82 ymax: 6119.25
-#> CRS: NA
+#> Projected CRS: Undefined Cartesian SRS with unknown unit
row.names(eire) <- as.character(eire$names)
st_crs(eire) <- "+proj=utm +zone=30 +ellps=airy +units=km"
+#> Warning: st_crs<- : replacing crs does not reproject data; use st_transform for that
eire.nb <- poly2nb(eire)
e.lm <- lm(OWNCONS ~ ROADACC, data=eire)
localmoran.sad(e.lm, nb=eire.nb)
diff --git a/docs/reference/localmoran.html b/docs/reference/localmoran.html
index 58060188..51483b97 100644
--- a/docs/reference/localmoran.html
+++ b/docs/reference/localmoran.html
@@ -21,7 +21,7 @@
diff --git a/docs/reference/localmoran.sad.html b/docs/reference/localmoran.sad.html
index 47e35071..1f1a24d7 100644
--- a/docs/reference/localmoran.sad.html
+++ b/docs/reference/localmoran.sad.html
@@ -25,7 +25,7 @@
@@ -260,16 +260,17 @@ See also
Examples
- eire <- st_read(system.file("shapes/eire.shp", package="spData")[1])
+ eire <- st_read(system.file("shapes/eire.gpkg", package="spData")[1])
#> Reading layer `eire' from data source
-#> `/home/rsb/lib/r_libs/spData/shapes/eire.shp' using driver `ESRI Shapefile'
+#> `/home/rsb/lib/r_libs/spData/shapes/eire.gpkg' using driver `GPKG'
#> Simple feature collection with 26 features and 10 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: -4.12 ymin: 5768 xmax: 300.82 ymax: 6119.25
-#> CRS: NA
+#> Projected CRS: Undefined Cartesian SRS with unknown unit
row.names(eire) <- as.character(eire$names)
st_crs(eire) <- "+proj=utm +zone=30 +ellps=airy +units=km"
+#> Warning: st_crs<- : replacing crs does not reproject data; use st_transform for that
eire.nb <- poly2nb(eire)
lw <- nb2listw(eire.nb)
e.lm <- lm(OWNCONS ~ ROADACC, data=eire)
diff --git a/docs/reference/localmoran_bv-1.png b/docs/reference/localmoran_bv-1.png
new file mode 100644
index 00000000..af9400b3
Binary files /dev/null and b/docs/reference/localmoran_bv-1.png differ
diff --git a/docs/reference/localmoran_bv-2.png b/docs/reference/localmoran_bv-2.png
new file mode 100644
index 00000000..cd4ad0c8
Binary files /dev/null and b/docs/reference/localmoran_bv-2.png differ
diff --git a/docs/reference/localmoran_bv.html b/docs/reference/localmoran_bv.html
index 7c162a43..1737d07d 100644
--- a/docs/reference/localmoran_bv.html
+++ b/docs/reference/localmoran_bv.html
@@ -17,7 +17,7 @@
@@ -73,7 +73,7 @@ Compute the Local Bivariate Moran's I Statistic
localmoran_bv(x, y, listw, nsim = 199, scale = TRUE, alternative="two.sided",
- iseed=1L, no_repeat_in_row=FALSE)
+ iseed=1L, no_repeat_in_row=FALSE, zero.policy=attr(listw, "zero.policy"))
@@ -107,6 +107,8 @@ Arguments
no_repeat_in_row
default FALSE
, if TRUE
, sample conditionally in each row without replacements to avoid duplicate values, https://github.com/r-spatial/spdep/issues/124
+ zero.policy
+default default attr(listw, "zero.policy")
as set when listw
was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA
@@ -135,14 +137,14 @@ Author
Examples
# load columbus data
-columbus <- st_read(system.file("shapes/columbus.shp", package="spData"))
+columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData"))
#> Reading layer `columbus' from data source
-#> `/home/rsb/lib/r_libs/spData/shapes/columbus.shp' using driver `ESRI Shapefile'
+#> `/home/rsb/lib/r_libs/spData/shapes/columbus.gpkg' using driver `GPKG'
#> Simple feature collection with 49 features and 20 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: 5.874907 ymin: 10.78863 xmax: 11.28742 ymax: 14.74245
-#> CRS: NA
+#> Projected CRS: Undefined Cartesian SRS with unknown unit
nb <- poly2nb(columbus)
listw <- nb2listw(nb)
set.seed(1)
@@ -247,8 +249,67 @@ Examples
#> [47,] 0.012 0.006
#> [48,] 0.544 0.272
#> [49,] 0.896 0.448
+#> attr(,"quadr")
+#> mean median pysal
+#> 1 Low-High Low-High Low-High
+#> 2 Low-Low Low-Low Low-Low
+#> 3 Low-Low Low-Low Low-Low
+#> 4 Low-High Low-High Low-High
+#> 5 High-Low High-Low High-Low
+#> 6 Low-Low Low-High Low-High
+#> 7 Low-Low Low-Low Low-Low
+#> 8 High-Low High-Low High-Low
+#> 9 Low-Low Low-Low Low-Low
+#> 10 Low-High Low-High Low-High
+#> 11 High-Low High-Low High-Low
+#> 12 High-Low High-Low High-Low
+#> 13 High-Low High-Low High-Low
+#> 14 High-Low High-Low High-Low
+#> 15 High-Low High-Low High-Low
+#> 16 High-Low High-Low High-Low
+#> 17 High-High High-High High-High
+#> 18 High-Low High-Low High-Low
+#> 19 High-Low High-Low High-Low
+#> 20 Low-High Low-High Low-High
+#> 21 High-Low High-High High-Low
+#> 22 Low-High Low-High Low-High
+#> 23 Low-High Low-High Low-High
+#> 24 High-Low High-Low High-Low
+#> 25 High-Low High-Low High-Low
+#> 26 High-Low High-Low High-Low
+#> 27 High-High High-High High-High
+#> 28 High-Low High-Low High-Low
+#> 29 High-Low High-Low High-Low
+#> 30 High-Low High-Low High-Low
+#> 31 Low-High Low-High Low-High
+#> 32 Low-High Low-High Low-High
+#> 33 High-High High-High High-High
+#> 34 Low-High Low-High Low-High
+#> 35 High-High High-High High-High
+#> 36 Low-High Low-High Low-High
+#> 37 High-Low High-Low High-Low
+#> 38 High-Low High-Low High-Low
+#> 39 Low-High Low-High Low-High
+#> 40 Low-High Low-High Low-High
+#> 41 Low-High Low-High Low-High
+#> 42 Low-High Low-High Low-High
+#> 43 High-Low High-Low High-Low
+#> 44 Low-Low Low-Low Low-Low
+#> 45 Low-High Low-High Low-High
+#> 46 Low-High Low-High Low-High
+#> 47 Low-High Low-High Low-High
+#> 48 Low-High Low-High Low-High
+#> 49 Low-Low Low-Low Low-Low
#> attr(,"class")
#> [1] "localmoran" "matrix" "array"
+columbus$hs <- hotspot(res, Prname="Pr(folded) Sim", cutoff=0.05,
+ quadrant.type="pysal", p.adjust="none")
+if (require("tmap", quietly=TRUE)) {
+ tm_shape(columbus) + tm_fill("hs")
+}
+
+moran.plot(x=columbus$CRIME, y=columbus$INC, listw=listw)
+
diff --git a/docs/reference/mat2listw.html b/docs/reference/mat2listw.html
index cf016b5a..1c76c98b 100644
--- a/docs/reference/mat2listw.html
+++ b/docs/reference/mat2listw.html
@@ -20,7 +20,7 @@
@@ -123,7 +123,7 @@ See also
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
col005 <- dnearneigh(st_coordinates(st_centroid(st_geometry(columbus),
of_largest_polygon=TRUE)), 0, 0.5, as.character(columbus$NEIGNO))
summary(col005)
diff --git a/docs/reference/moran.html b/docs/reference/moran.html
index 0139f4ce..0a794be5 100644
--- a/docs/reference/moran.html
+++ b/docs/reference/moran.html
@@ -20,7 +20,7 @@
diff --git a/docs/reference/moran.mc.html b/docs/reference/moran.mc.html
index cc44a80b..b559213d 100644
--- a/docs/reference/moran.mc.html
+++ b/docs/reference/moran.mc.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/moran.plot-4.png b/docs/reference/moran.plot-4.png
new file mode 100644
index 00000000..cd4ad0c8
Binary files /dev/null and b/docs/reference/moran.plot-4.png differ
diff --git a/docs/reference/moran.plot-5.png b/docs/reference/moran.plot-5.png
new file mode 100644
index 00000000..ff6436a3
Binary files /dev/null and b/docs/reference/moran.plot-5.png differ
diff --git a/docs/reference/moran.plot.html b/docs/reference/moran.plot.html
index 8aab3208..0e8d5e38 100644
--- a/docs/reference/moran.plot.html
+++ b/docs/reference/moran.plot.html
@@ -20,7 +20,7 @@
@@ -78,8 +78,8 @@ Moran scatterplot
- moran.plot(x, listw, zero.policy=attr(listw, "zero.policy"), spChk=NULL, labels=NULL,
- xlab=NULL, ylab=NULL, quiet=NULL, plot=TRUE, return_df=TRUE, ...)
+ moran.plot(x, listw, y=NULL, zero.policy=attr(listw, "zero.policy"), spChk=NULL,
+ labels=NULL, xlab=NULL, ylab=NULL, quiet=NULL, plot=TRUE, return_df=TRUE, ...)
@@ -90,6 +90,9 @@ Arguments
listw
a listw
object created for example by nb2listw
+ y
+an optional numeric vector the same length as the neighbours list in listw for a bi-variate plot
+
zero.policy
default attr(listw, "zero.policy")
as set when listw
was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA
@@ -162,6 +165,20 @@ Examples
xlab(xname) + ylab(paste0("Spatially lagged ", xname))
}
+columbus <- st_read(system.file("shapes/columbus.shp", package="spData"))
+#> Reading layer `columbus' from data source
+#> `/home/rsb/lib/r_libs/spData/shapes/columbus.shp' using driver `ESRI Shapefile'
+#> Simple feature collection with 49 features and 20 fields
+#> Geometry type: POLYGON
+#> Dimension: XY
+#> Bounding box: xmin: 5.874907 ymin: 10.78863 xmax: 11.28742 ymax: 14.74245
+#> CRS: NA
+nb <- poly2nb(columbus)
+listw <- nb2listw(nb)
+moran.plot(x=columbus$CRIME, y=columbus$INC, listw=listw)
+
+moran.plot(x=columbus$INC, y=columbus$CRIME, listw=listw)
+
diff --git a/docs/reference/moran.test.html b/docs/reference/moran.test.html
index 91632932..f5cb423a 100644
--- a/docs/reference/moran.test.html
+++ b/docs/reference/moran.test.html
@@ -17,7 +17,7 @@
@@ -390,7 +390,7 @@ Examples
#> Moran I statistic Expectation Variance
#> 0.212782897 -0.020833333 0.008784908
#>
-columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
col_geoms <- st_geometry(columbus)
col_geoms[1] <- st_buffer(col_geoms[1], dist=-0.05)
st_geometry(columbus) <- col_geoms
diff --git a/docs/reference/moran_bv.html b/docs/reference/moran_bv.html
index 9c538aac..2a620d10 100644
--- a/docs/reference/moran_bv.html
+++ b/docs/reference/moran_bv.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/mstree.html b/docs/reference/mstree.html
index 7c1fbcac..203ec09b 100644
--- a/docs/reference/mstree.html
+++ b/docs/reference/mstree.html
@@ -21,7 +21,7 @@
@@ -124,9 +124,10 @@ Author
Examples
### loading data
-bh <- st_read(system.file("etc/shapes/bhicv.shp",
+bh <- st_read(system.file("etc/shapes/bhicv.gpkg",
package="spdep")[1], quiet=TRUE)
st_crs(bh) <- "OGC:CRS84"
+#> Warning: st_crs<- : replacing crs does not reproject data; use st_transform for that
### data padronized
dpad <- data.frame(scale(as.data.frame(bh)[,5:8]))
diff --git a/docs/reference/nb2INLA.html b/docs/reference/nb2INLA.html
index f2b9aecd..a9bc4c28 100644
--- a/docs/reference/nb2INLA.html
+++ b/docs/reference/nb2INLA.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/nb2WB.html b/docs/reference/nb2WB.html
index a52918e8..0e6fe97a 100644
--- a/docs/reference/nb2WB.html
+++ b/docs/reference/nb2WB.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/nb2blocknb.html b/docs/reference/nb2blocknb.html
index d1a6125f..a59809c4 100644
--- a/docs/reference/nb2blocknb.html
+++ b/docs/reference/nb2blocknb.html
@@ -20,7 +20,7 @@
diff --git a/docs/reference/nb2lines.html b/docs/reference/nb2lines.html
index 10377d2f..4a024a44 100644
--- a/docs/reference/nb2lines.html
+++ b/docs/reference/nb2lines.html
@@ -17,7 +17,7 @@
@@ -137,7 +137,7 @@ See also
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
col.gal.nb <- read.gal(system.file("weights/columbus.gal", package="spData")[1])
res <- listw2lines(nb2listw(col.gal.nb), st_geometry(columbus))
summary(res)
@@ -157,13 +157,12 @@ Examples
#> Max. :0.5000
tf <- paste0(tempfile(), ".gpkg")
st_write(res, dsn=tf, driver="GPKG")
-#> writing: substituting ENGCRS["Undefined Cartesian SRS with unknown unit"] for missing CRS
-#> Writing layer `fileb5454757b8497' to data source
-#> `/tmp/Rtmpo2JxkN/fileb5454757b8497.gpkg' using driver `GPKG'
+#> Writing layer `fileeaf0c54d25a74' to data source
+#> `/tmp/RtmprsAvOs/fileeaf0c54d25a74.gpkg' using driver `GPKG'
#> Writing 230 features with 5 fields and geometry type Line String.
inMap <- st_read(tf)
-#> Reading layer `fileb5454757b8497' from data source
-#> `/tmp/Rtmpo2JxkN/fileb5454757b8497.gpkg' using driver `GPKG'
+#> Reading layer `fileeaf0c54d25a74' from data source
+#> `/tmp/RtmprsAvOs/fileeaf0c54d25a74.gpkg' using driver `GPKG'
#> Simple feature collection with 230 features and 5 fields
#> Geometry type: LINESTRING
#> Dimension: XY
@@ -202,7 +201,7 @@ Examples
#> min max
#> x 6.221943 10.95359
#> y 11.010031 14.36908
-#> Is projected: NA
+#> Is projected: TRUE
#> proj4string : [NA]
#> Data attributes:
#> i j i_ID j_ID
diff --git a/docs/reference/nb2listw.html b/docs/reference/nb2listw.html
index 1302cfd1..69582d1e 100644
--- a/docs/reference/nb2listw.html
+++ b/docs/reference/nb2listw.html
@@ -17,7 +17,7 @@
@@ -141,7 +141,7 @@ See also
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
col.gal.nb <- read.gal(system.file("weights/columbus.gal", package="spData")[1])
coords <- st_coordinates(st_centroid(columbus))
#> Warning: st_centroid assumes attributes are constant over geometries
diff --git a/docs/reference/nb2listwdist.html b/docs/reference/nb2listwdist.html
index 82e7dfe5..24095d29 100644
--- a/docs/reference/nb2listwdist.html
+++ b/docs/reference/nb2listwdist.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/nb2mat.html b/docs/reference/nb2mat.html
index fb844ebf..a391266c 100644
--- a/docs/reference/nb2mat.html
+++ b/docs/reference/nb2mat.html
@@ -17,7 +17,7 @@
@@ -120,7 +120,7 @@ See also
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
col005 <- dnearneigh(st_coordinates(st_centroid(st_geometry(columbus),
of_largest_polygon=TRUE)), 0, 0.5, as.character(columbus$NEIGNO))
summary(col005)
diff --git a/docs/reference/nbcosts.html b/docs/reference/nbcosts.html
index 31c2e126..344dcf30 100644
--- a/docs/reference/nbcosts.html
+++ b/docs/reference/nbcosts.html
@@ -19,7 +19,7 @@
diff --git a/docs/reference/nbdists.html b/docs/reference/nbdists.html
index 74a10810..c84b669c 100644
--- a/docs/reference/nbdists.html
+++ b/docs/reference/nbdists.html
@@ -20,7 +20,7 @@
@@ -112,7 +112,7 @@ See also
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
col.gal.nb <- read.gal(system.file("weights/columbus.gal", package="spData")[1])
coords <- st_coordinates(st_centroid(columbus))
#> Warning: st_centroid assumes attributes are constant over geometries
diff --git a/docs/reference/nblag.html b/docs/reference/nblag.html
index 405cf38b..85843ee7 100644
--- a/docs/reference/nblag.html
+++ b/docs/reference/nblag.html
@@ -17,7 +17,7 @@
@@ -107,7 +107,7 @@ See also
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
col.gal.nb <- read.gal(system.file("weights/columbus.gal", package="spData")[1])
coords <- st_coordinates(st_centroid(columbus))
#> Warning: st_centroid assumes attributes are constant over geometries
diff --git a/docs/reference/nboperations.html b/docs/reference/nboperations.html
index ea2355c5..32f9ec8c 100644
--- a/docs/reference/nboperations.html
+++ b/docs/reference/nboperations.html
@@ -17,7 +17,7 @@
@@ -118,7 +118,7 @@ See also
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
col.gal.nb <- read.gal(system.file("weights/columbus.gal", package="spData")[1])
coords <- st_coordinates(st_centroid(columbus))
#> Warning: st_centroid assumes attributes are constant over geometries
diff --git a/docs/reference/p.adjustSP.html b/docs/reference/p.adjustSP.html
index 022e1f11..76bd3727 100644
--- a/docs/reference/p.adjustSP.html
+++ b/docs/reference/p.adjustSP.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/plot.mst.html b/docs/reference/plot.mst.html
index 70cda21c..cd84ab15 100644
--- a/docs/reference/plot.mst.html
+++ b/docs/reference/plot.mst.html
@@ -18,7 +18,7 @@
diff --git a/docs/reference/plot.nb.html b/docs/reference/plot.nb.html
index dac1d594..da5f58ed 100644
--- a/docs/reference/plot.nb.html
+++ b/docs/reference/plot.nb.html
@@ -17,7 +17,7 @@
@@ -122,7 +122,7 @@ See also
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
col.gal.nb <- read.gal(system.file("weights/columbus.gal", package="spData")[1])
plot(col.gal.nb, st_geometry(columbus))
title(main="GAL order 1 links with first nearest neighbours in red", cex.main=0.6)
diff --git a/docs/reference/plot.skater.html b/docs/reference/plot.skater.html
index 411d64f5..94008f96 100644
--- a/docs/reference/plot.skater.html
+++ b/docs/reference/plot.skater.html
@@ -18,7 +18,7 @@
diff --git a/docs/reference/poly2nb-4.png b/docs/reference/poly2nb-4.png
index 5a9c62bc..c4cc58e3 100644
Binary files a/docs/reference/poly2nb-4.png and b/docs/reference/poly2nb-4.png differ
diff --git a/docs/reference/poly2nb.html b/docs/reference/poly2nb.html
index 680e11cf..7b8f445c 100644
--- a/docs/reference/poly2nb.html
+++ b/docs/reference/poly2nb.html
@@ -17,7 +17,7 @@
@@ -120,7 +120,7 @@ See also
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
col.gal.nb <- read.gal(system.file("weights/columbus.gal", package="spData")[1])
coords <- st_coordinates(st_centroid(st_geometry(columbus)))
xx <- poly2nb(as(columbus, "Spatial"))
@@ -171,13 +171,13 @@ Examples
plot(st_geometry(columbus), col=fg)
title(main="Region with largest number of contiguities", cex.main=0.6)
-nc.sids <- st_read(system.file("shapes/sids.shp", package="spData")[1], quiet=TRUE)
+nc.sids <- st_read(system.file("shapes/sids.gpkg", package="spData")[1], quiet=TRUE)
system.time(xxnb <- poly2nb(nc.sids))
#> user system elapsed
-#> 0.021 0.000 0.021
+#> 0.034 0.000 0.034
system.time(xxnb <- poly2nb(as(nc.sids, "Spatial")))
#> user system elapsed
-#> 0.038 0.000 0.038
+#> 0.063 0.000 0.064
plot(st_geometry(nc.sids))
plot(xxnb, st_coordinates(st_centroid(nc.sids)), add=TRUE, col="blue")
#> Warning: st_centroid assumes attributes are constant over geometries
diff --git a/docs/reference/probmap.html b/docs/reference/probmap.html
index 5268f74b..99bb15ed 100644
--- a/docs/reference/probmap.html
+++ b/docs/reference/probmap.html
@@ -17,7 +17,7 @@
@@ -124,7 +124,7 @@ See also
Examples
- auckland <- st_read(system.file("shapes/auckland.shp", package="spData")[1], quiet=TRUE)
+ auckland <- st_read(system.file("shapes/auckland.gpkg", package="spData")[1], quiet=TRUE)
res <- probmap(auckland$M77_85, 9*auckland$Und5_81)
rt <- sum(auckland$M77_85)/sum(9*auckland$Und5_81)
ppois_pmap <- numeric(length(auckland$Und5_81))
diff --git a/docs/reference/prunecost.html b/docs/reference/prunecost.html
index fdb62893..297d05d0 100644
--- a/docs/reference/prunecost.html
+++ b/docs/reference/prunecost.html
@@ -22,7 +22,7 @@
diff --git a/docs/reference/prunemst.html b/docs/reference/prunemst.html
index 1ec985b5..ab6665e0 100644
--- a/docs/reference/prunemst.html
+++ b/docs/reference/prunemst.html
@@ -18,7 +18,7 @@
diff --git a/docs/reference/read.gal.html b/docs/reference/read.gal.html
index 1754ceca..3eb780e5 100644
--- a/docs/reference/read.gal.html
+++ b/docs/reference/read.gal.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/read.gwt2nb.html b/docs/reference/read.gwt2nb.html
index 647dccd2..f27cec92 100644
--- a/docs/reference/read.gwt2nb.html
+++ b/docs/reference/read.gwt2nb.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/rotation.html b/docs/reference/rotation.html
index 99a03494..f282a87f 100644
--- a/docs/reference/rotation.html
+++ b/docs/reference/rotation.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/set.mcOption.html b/docs/reference/set.mcOption.html
index e1692b86..17f20db5 100644
--- a/docs/reference/set.mcOption.html
+++ b/docs/reference/set.mcOption.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/set.spChkOption.html b/docs/reference/set.spChkOption.html
index 28b1eeac..78108fe1 100644
--- a/docs/reference/set.spChkOption.html
+++ b/docs/reference/set.spChkOption.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/skater.html b/docs/reference/skater.html
index fcf2e525..95404976 100644
--- a/docs/reference/skater.html
+++ b/docs/reference/skater.html
@@ -20,7 +20,7 @@
@@ -178,9 +178,10 @@ See also
Examples
### loading data
-bh <- st_read(system.file("etc/shapes/bhicv.shp",
+bh <- st_read(system.file("etc/shapes/bhicv.gpkg",
package="spdep")[1], quiet=TRUE)
st_crs(bh) <- "OGC:CRS84"
+#> Warning: st_crs<- : replacing crs does not reproject data; use st_transform for that
### data standardized
dpad <- data.frame(scale(as.data.frame(bh)[,5:8]))
@@ -299,7 +300,7 @@ Examples
### calculating costs
system.time(lcosts <- nbcosts(bh.nb, dpad))
#> user system elapsed
-#> 0.047 0.000 0.049
+#> 0.044 0.000 0.045
### making listw
nb.w <- nb2listw(bh.nb, lcosts, style="B")
### find a minimum spanning tree
@@ -322,7 +323,7 @@ Examples
### calculating costs
system.time(plcosts <- nbcosts(bh.nb, dpad))
#> user system elapsed
-#> 0.053 0.000 0.054
+#> 0.039 0.001 0.041
all.equal(lcosts, plcosts, check.attributes=FALSE)
#> [1] TRUE
### making listw
diff --git a/docs/reference/sp.correlogram.html b/docs/reference/sp.correlogram.html
index 786a7055..47a0ba94 100644
--- a/docs/reference/sp.correlogram.html
+++ b/docs/reference/sp.correlogram.html
@@ -18,7 +18,7 @@
@@ -168,7 +168,7 @@ See also
Examples
- nc.sids <- st_read(system.file("shapes/sids.shp", package="spData")[1], quiet=TRUE)
+ nc.sids <- st_read(system.file("shapes/sids.gpkg", package="spData")[1], quiet=TRUE)
rn <- as.character(nc.sids$FIPS)
ncCC89_nb <- read.gal(system.file("weights/ncCC89.gal", package="spData")[1],
region.id=rn)
diff --git a/docs/reference/sp.mantel.mc.html b/docs/reference/sp.mantel.mc.html
index a44ef13f..33d2d5ed 100644
--- a/docs/reference/sp.mantel.mc.html
+++ b/docs/reference/sp.mantel.mc.html
@@ -23,7 +23,7 @@
diff --git a/docs/reference/spdep-defunct.html b/docs/reference/spdep-defunct.html
index 1230913f..93dc9a74 100644
--- a/docs/reference/spdep-defunct.html
+++ b/docs/reference/spdep-defunct.html
@@ -18,7 +18,7 @@
diff --git a/docs/reference/spdep.html b/docs/reference/spdep.html
index 21869c8f..4f2abdbd 100644
--- a/docs/reference/spdep.html
+++ b/docs/reference/spdep.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/spweights.constants.html b/docs/reference/spweights.constants.html
index 64703cc3..158ef217 100644
--- a/docs/reference/spweights.constants.html
+++ b/docs/reference/spweights.constants.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/ssw.html b/docs/reference/ssw.html
index 5441d9aa..74ce3e47 100644
--- a/docs/reference/ssw.html
+++ b/docs/reference/ssw.html
@@ -18,7 +18,7 @@
diff --git a/docs/reference/subset.listw.html b/docs/reference/subset.listw.html
index 690cfb3c..e949084f 100644
--- a/docs/reference/subset.listw.html
+++ b/docs/reference/subset.listw.html
@@ -17,7 +17,7 @@
@@ -136,7 +136,7 @@ Examples
#> Weights constants summary:
#> n nn S0 S1 S2
#> W 43 1849 43 19.26584 178.4604
-columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
nb <- poly2nb(columbus)
lw <- nb2listw(nb, style="W")
attr(lw, "zero.policy")
diff --git a/docs/reference/subset.nb.html b/docs/reference/subset.nb.html
index 721b4a55..0bb38f41 100644
--- a/docs/reference/subset.nb.html
+++ b/docs/reference/subset.nb.html
@@ -17,7 +17,7 @@
@@ -107,7 +107,7 @@ See also
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
col.gal.nb <- read.gal(system.file("weights/columbus.gal", package="spData")[1])
coords <- st_coordinates(st_centroid(columbus))
#> Warning: st_centroid assumes attributes are constant over geometries
diff --git a/docs/reference/summary.nb.html b/docs/reference/summary.nb.html
index bbc47325..d0c77384 100644
--- a/docs/reference/summary.nb.html
+++ b/docs/reference/summary.nb.html
@@ -19,7 +19,7 @@
@@ -125,7 +125,7 @@ See also
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
col.gal.nb <- read.gal(system.file("weights/columbus.gal", package="spData")[1])
coords <- st_centroid(st_geometry(columbus), of_largest_polygon=TRUE)
col.gal.nb
diff --git a/docs/reference/testnb.html b/docs/reference/testnb.html
index 6f4a8529..c1587118 100644
--- a/docs/reference/testnb.html
+++ b/docs/reference/testnb.html
@@ -21,7 +21,7 @@
@@ -123,7 +123,7 @@ See also
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
col.gal.nb <- read.gal(system.file("weights/columbus.gal", package="spData")[1])
coords <- st_coordinates(st_centroid(columbus))
#> Warning: st_centroid assumes attributes are constant over geometries
diff --git a/docs/reference/tolerance.nb.html b/docs/reference/tolerance.nb.html
index fbeab9d7..a3083641 100644
--- a/docs/reference/tolerance.nb.html
+++ b/docs/reference/tolerance.nb.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/tri2nb.html b/docs/reference/tri2nb.html
index 90183f55..aa94f265 100644
--- a/docs/reference/tri2nb.html
+++ b/docs/reference/tri2nb.html
@@ -20,7 +20,7 @@
@@ -121,7 +121,7 @@ See also
Examples
- columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+ columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
coords <- st_centroid(st_geometry(columbus), of_largest_polygon=TRUE)
ind <- row.names(columbus)
suppressPackageStartupMessages(require(deldir))
diff --git a/docs/reference/write.nb.gal.html b/docs/reference/write.nb.gal.html
index 0dbf5c0c..58f733e9 100644
--- a/docs/reference/write.nb.gal.html
+++ b/docs/reference/write.nb.gal.html
@@ -17,7 +17,7 @@
diff --git a/man/localmoran_bv.Rd b/man/localmoran_bv.Rd
index 52adfb0c..b0eef582 100644
--- a/man/localmoran_bv.Rd
+++ b/man/localmoran_bv.Rd
@@ -3,7 +3,7 @@
\title{Compute the Local Bivariate Moran's I Statistic}
\usage{
localmoran_bv(x, y, listw, nsim = 199, scale = TRUE, alternative="two.sided",
- iseed=1L, no_repeat_in_row=FALSE)
+ iseed=1L, no_repeat_in_row=FALSE, zero.policy=attr(listw, "zero.policy"))
}
\arguments{
\item{x}{a numeric vector of same length as \code{y}.}
@@ -19,7 +19,7 @@ localmoran_bv(x, y, listw, nsim = 199, scale = TRUE, alternative="two.sided",
\item{alternative}{a character string specifying the alternative hypothesis, must be one of "greater" (default), "two.sided", or "less".}
\item{iseed}{default NULL, used to set the seed for possible parallel RNGs.}
\item{no_repeat_in_row}{default \code{FALSE}, if \code{TRUE}, sample conditionally in each row without replacements to avoid duplicate values, \url{https://github.com/r-spatial/spdep/issues/124}}
-
+ \item{zero.policy}{default default \code{attr(listw, "zero.policy")} as set when \code{listw} was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA}
}
\value{
a \code{data.frame} containing two columns \code{Ib} and \code{p_sim} containing the local bivariate Moran's I and simulated p-values respectively.
@@ -42,6 +42,12 @@ nb <- poly2nb(columbus)
listw <- nb2listw(nb)
set.seed(1)
(res <- localmoran_bv(columbus$CRIME, columbus$INC, listw, nsim = 499))
+columbus$hs <- hotspot(res, Prname="Pr(folded) Sim", cutoff=0.05,
+ quadrant.type="pysal", p.adjust="none")
+if (require("tmap", quietly=TRUE)) {
+ tm_shape(columbus) + tm_fill("hs")
+}
+moran.plot(x=columbus$CRIME, y=columbus$INC, listw=listw)
}
\references{
Anselin, Luc, Ibnu Syabri, and Oleg Smirnov. 2002. “Visualizing Multivariate Spatial Correlation with Dynamically Linked Windows.” In New Tools for Spatial Data Analysis: Proceedings of the Specialist Meeting, edited by Luc Anselin and Sergio Rey. University of California, Santa Barbara: Center for Spatially Integrated Social Science (CSISS).
diff --git a/man/moran.plot.Rd b/man/moran.plot.Rd
index 8175990b..76d3f8a8 100644
--- a/man/moran.plot.Rd
+++ b/man/moran.plot.Rd
@@ -8,12 +8,13 @@ between the data and the lag. If zero policy is TRUE, such observations
are also marked if they occur.
}
\usage{
-moran.plot(x, listw, zero.policy=attr(listw, "zero.policy"), spChk=NULL, labels=NULL,
- xlab=NULL, ylab=NULL, quiet=NULL, plot=TRUE, return_df=TRUE, ...)
+moran.plot(x, listw, y=NULL, zero.policy=attr(listw, "zero.policy"), spChk=NULL,
+ labels=NULL, xlab=NULL, ylab=NULL, quiet=NULL, plot=TRUE, return_df=TRUE, ...)
}
\arguments{
\item{x}{a numeric vector the same length as the neighbours list in listw}
\item{listw}{a \code{listw} object created for example by \code{nb2listw}}
+ \item{y}{an optional numeric vector the same length as the neighbours list in listw for a bi-variate plot}
\item{zero.policy}{default \code{attr(listw, "zero.policy")} as set when \code{listw} was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA}
\item{spChk}{should the data vector names be checked against the spatial objects for identity integrity, TRUE, or FALSE, default NULL to use \code{get.spChkOption()}}
\item{labels}{character labels for points with high influence measures, if set to FALSE, no labels are plotted for points with large influence}
@@ -54,5 +55,10 @@ if (require(ggplot2, quietly=TRUE)) {
geom_text(data=mp[mp$is_inf,], aes(x=x, y=wx, label=labels, vjust=1.5)) +
xlab(xname) + ylab(paste0("Spatially lagged ", xname))
}
+columbus <- st_read(system.file("shapes/columbus.shp", package="spData"))
+nb <- poly2nb(columbus)
+listw <- nb2listw(nb)
+moran.plot(x=columbus$CRIME, y=columbus$INC, listw=listw)
+moran.plot(x=columbus$INC, y=columbus$CRIME, listw=listw)
}
\keyword{spatial}