Planar point pattern: 30 points
window: polygonal boundary
enclosing rectangle: [0, 1] x [0, 1] units
…and back to sf
st_as_sf(pp1) |>head(4)
Simple feature collection with 4 features and 1 field
Geometry type: GEOMETRY
Dimension: XY
Bounding box: xmin: 0 ymin: 0 xmax: 1 ymax: 1
CRS: NA
label geom
1 window POLYGON ((1 1, 0 1, 0 0, 1 ...
2 point POINT (0.8878369 0.5102393)
3 point POINT (0.6425945 0.6621732)
4 point POINT (0.2986297 0.9070111)
The window comes back as a feature with label = "window", the points with label = "point".
Observation window
Same points, different window
square circle
30.000000 6.634487
Quadrat counts depend on the window
Density depends on the window
The window is part of the data: it defines where points could have occurred. Defaults like the bounding box or convex hull are guesses.
Chi-squared test of CSR using quadrat counts
data: bei
X2 = 781.26, df = 7, p-value < 2.2e-16
alternative hypothesis: two.sided
Quadrats: 4 by 2 grid of tiles
Conditional Monte Carlo test of CSR using quadrat counts
Test statistic: Pearson X2 statistic
data: pp1
X2 = 7.8, p-value = 0.892
alternative hypothesis: two.sided
Quadrats: 9 tiles (irregular windows)
\(e_{ij}\) is the edge correction: neighbours outside \(W\) are never seen (border, translation, isotropic corrections).
L function and pair correlation
\(L(r) = \sqrt{K(r)/\pi}\): under CSR \(L(r) = r\), so we plot \(L(r) - r\) (zero under CSR)
\(g(r) = K'(r) / (2\pi r)\): non-cumulative, refers to pairs at distance exactly\(r\)
\(g > 1\): clustering at that distance; \(g < 1\): inhibition
Monte Carlo envelopes
Simulate nsim CSR patterns (same \(n\), same \(W\)), compute the function for each, and take the min/max as a band.
Above the band: clustered at that distance. Below: regular.
Pointwise vs. global envelopes
Pointwise (default): with nsim = 39, the significance level of 5% holds only for one distance \(r\) chosen in advance. Scanning all \(r\) is multiple testing.
Global (global = TRUE): a band for the whole curve at once, with α = 1/(nsim + 1)
Many events can only occur on a network: traffic accidents, street crime, street trees, ambulance calls, spines along a dendrite
Planar methods assume points could be anywhere in \(W\)
Euclidean distance ≠ shortest-path distance along the network
Intensity is per unit length (accidents per metre of street), not per area
Random on streets ≠ random in the plane
spatstat classes: linnet and lpp
Point pattern on linear network
116 points
Multitype, with possible types:
assault burglary cartheft damage robbery theft trespass
Linear network with 338 vertices and 503 lines
Enclosing window: rectangle = [0.3894, 1281.9863] x [153.1035, 1276.5602] feet
Intensity on a network
The kernel spreads along the streets (heat equation), not across blocks
Result is a linim: an image living on the network
densityQuick.lpp() is a fast approximation for large networks
Network K function
Distances measured along the network (shortest path)
Normalised so that CSR on the network gives \(K_L(r) = r\)
Here: crimes cluster even after accounting for the network
Sampling and simulation
Spatial sampling with st_sample() (book §11.4)
Any spatstat simulator can be called from sf via type =.
Simulating points on the sphere (book §11.5)
Uniform longitude/latitude piles points up at the poles. sf + s2 samples uniformly on the sphere.
Wrap-up
Python for your projects
pointpats (PySAL): quadrat statistics, centrography, G/F/J/K/L functions, simulation of CSR and cluster processes
spaghetti (PySAL): spatial networks, snapping points, network K function
Gest(), Fest(), Jest(), Kest()/Lest(), pcf(); Kinhom() if λ varies
On a network?
linnet, lpp, density.lpp(), linearK(), spNetwork
References
Pebesma, E. & Bivand, R. (2023). Spatial Data Science: With Applications in R. CRC Press. Ch. 11. https://r-spatial.org/book/
Baddeley, A., Rubak, E. & Turner, R. (2015). Spatial Point Patterns: Methodology and Applications with R. CRC Press.
Baddeley, A., Nair, G., Rakshit, S., McSwiggan, G. & Davies, T. M. (2021). Analysing point patterns on networks — a review. Spatial Statistics, 42, 100435.
Gelb, J. (2021). spNetwork: A package for network kernel density estimation. The R Journal, 13(2).
Okabe, A. & Sugihara, K. (2012). Spatial Analysis Along Networks. Wiley.