Learn R Programming

⚠️There's a newer version (3.3-1) of this package.Take me there.

spatstat (version 1.13-4)

Spatial Point Pattern analysis, model-fitting, simulation, tests

Description

A package for analysing spatial data, mainly Spatial Point Patterns, including multitype/marked points and spatial covariates, in any two-dimensional spatial region. Contains functions for plotting spatial data, exploratory data analysis, model-fitting, simulation, spatial sampling, model diagnostics, and formal inference. Data types include point patterns, line segment patterns, spatial windows, and pixel images. Point process models can be fitted to point pattern data. Cluster type models are fitted by the method of minimum contrast. Very general Gibbs point process models can be fitted to point pattern data using a function ppm similar to lm or glm. Models may include dependence on covariates, interpoint interaction and dependence on marks. Fitted models can be simulated automatically. Also provides facilities for formal inference (such as chi-squared tests) and model diagnostics (including simulation envelopes, residuals, residual plots and Q-Q plots).

Copy Link

Version

Install

install.packages('spatstat')

Monthly Downloads

16,590

Version

1.13-4

License

GPL (>= 2)

Maintainer

Adrian Baddeley

Last Published

March 22nd, 2025

Functions in spatstat (1.13-4)

Softcore

The Soft Core Point Process Model
as.matrix.im

Convert Pixel Image to Matrix
chorley

Chorley-Ribble Cancer Data
Jmulti

Marked J Function
Lest

L-function
Kcross.inhom

Inhomogeneous Cross K Function
Kdot

Multitype K Function (i-to-any)
bdist.pixels

Distance to Boundary of Window
SatPiece

Piecewise Constant Saturated Pairwise Interaction Point Process Model
cut.ppp

Convert Point Pattern Marks from Numeric to Factor
as.data.frame.ppp

Coerce Point Pattern to a Data Frame
eval.hyper

Evaluate an Expression in Each Row of a Hyperframe
PairPiece

The Piecewise Constant Pairwise Interaction Point Process Model
allstats

Calculate four standard summary functions of a point pattern.
humberside

Humberside Data on Childhood Leukaemia and Lymphoma
cells

Biological Cells Point Pattern
demopat

Artificial Data Point Pattern
compatible.fasp

Test Whether Two Function Arrays Are Compatible
bramblecanes

Hutchings' Bramble Canes data
dilate.owin

Dilate a Window
Gest

Nearest Neighbour Distance Function G
Kcross

Multitype K Function (Cross-type)
Gmulti

Marked Nearest Neighbour Distance Function
is.marked

Test Whether Marks Are Present
MultiStraussHard

The Multitype/Hard Core Strauss Point Process Model
append.psp

Combine Two Line Segment Patterns
hamster

Aherne's hamster tumour data
eem

Exponential Energy Marks
eval.im

Evaluate Expression Involving Pixel Images
lengths.psp

Lengths of Line Segments
Ldot

Multitype L-function (i-to-any)
BadGey

Hybrid Geyer Point Process Model
StraussHard

The Strauss / Hard Core Point Process Model
eval.fv

Evaluate Expression Involving Functions
is.marked.ppp

Test Whether A Point Pattern is Marked
rotate.psp

Rotate a Line Segment Pattern
ord.family

Ord Interaction Process Family
rmpoispp

Generate Multitype Poisson Point Pattern
Kinhom

Inhomogeneous K-function
clarkevans

Clark and Evans Aggregation Index
distmap

Distance Map
AreaInter

The Area Interaction Point Process Model
Strauss

The Strauss Point Process Model
Iest

Estimate the I-function
pairdist.psp

Pairwise distances between line segments
crossdist.default

Pairwise distances between two different sets of points
localK

Neighbourhood density function
alltypes

Calculate Summary Statistic for All Types in a Multitype Point Pattern
scanpp

Read Point Pattern From Data File
pcf.fv

Pair Correlation Function obtained from K Function
Ord

Generic Ord Interaction model
cut.im

Convert Pixel Image from Numeric to Factor
distmap.psp

Distance Map of Line Segment Pattern
as.mask

Pixel Image Approximation of a Window
pcf.fasp

Pair Correlation Function obtained from array of K functions
stieltjes

Compute Integral of Function Against Cumulative Distribution
distmap.ppp

Distance Map of Point Pattern
harmonic

Basis for Harmonic Functions
corners

Corners of a rectangle
crossdist

Pairwise distances
affine.ppp

Apply Affine Transformation To Point Pattern
spatstat

The Spatstat Package
rotate.ppp

Rotate a Point Pattern
areadiff

Difference of Disc Areas
marktable

Tabulate Marks in Neighbourhood of Every Point in a Point Pattern
logLik.ppm

Log Likelihood for Poisson Point Process Model
spatstat-deprecated

Deprecated spatstat functions
DiggleGratton

Diggle-Gratton model
as.ppp

Convert Data To Class ppp
as.im

Convert to Pixel Image
markstat

Summarise Marks in Every Neighbourhood in a Point Pattern
Gdot

Multitype Nearest Neighbour Distance Function (i-to-any)
bei

Tropical rain forest trees
diameter

Diameter of a Window
centroid.owin

Centroid of a window
Fest

Estimate the empty space function F
print.psp

Print Brief Details of a Line Segment Pattern Dataset
pcf

Pair Correlation Function
bdist.points

Distance to Boundary of Window
ripras

Estimate window from points alone
anemones

Beadlet Anemones Data
Gcross

Multitype Nearest Neighbour Distance Function (i-to-j)
rpoisline

Generate Poisson Random Line Process
Kest

K-function
compatible.im

Test Whether Two Pixel Images Are Compatible
data.ppm

Extract Original Data from a Fitted Point Process Model
plot.ppm

plot a Fitted Point Process Model
plot.fasp

Plot a Function Array
Kest.fft

K-function using FFT
hyperframe

Hyper Data Frame
discretise

Safely Convert Point Pattern Window to Binary Mask
Jdot

Multitype J Function (i-to-any)
rotate

Rotate
convexhull.xy

Convex Hull of Points
LennardJones

The Lennard-Jones Potential
eroded.areas

Areas of Morphological Erosions
rpoispp

Generate Poisson Point Pattern
Jest

Estimate the J-function
density.splitppp

Kernel Smoothed Intensity of Split Point Pattern
bounding.box

Bounding Box of a Window or Point Pattern
is.subset.owin

Determine Whether One Window is Contained In Another
pairdist.ppp

Pairwise distances
density.psp

Kernel Smoothing of Line Segment Pattern
OrdThresh

Ord's Interaction model
as.rectangle

Window Frame
coef.ppm

Coefficients of Fitted Point Process Model
as.owin

Convert Data To Class owin
ppp

Create a Point Pattern
dirichlet.weights

Compute Quadrature Weights Based on Dirichlet Tessellation
im

Create a Pixel Image Object
default.dummy

Generate a Default Pattern of Dummy Points
im.object

Class of Images
levelset

Level Set of a Pixel Image
duplicated.ppp

Determine Duplicated Points in a Spatial Point Pattern
quadratcount

Quadrat counting for a point pattern
gridweights

Compute Quadrature Weights Based on Grid Counts
spokes

Spokes pattern of dummy points
plot.splitppp

Plot a List of Point Patterns
rescale.psp

Convert Line Segment Pattern to Another Unit of Length
rshift.ppp

Randomly Shift a Point Pattern
clickpoly

Interactively Define a Polygon
fv.object

Data Frames of Function Values
Saturated

Saturated Pairwise Interaction model
crossdist.ppp

Pairwise distances between two different point patterns
distmap.owin

Distance Map of Window
gpc2owin

Convert Polygonal Region into Different Format
interp.im

Interpolate a Pixel Image
rmhstart

Determine Initial State for Metropolis-Hastings Simulation.
affine.owin

Apply Affine Transformation To Window
is.multitype.ppm

Test Whether A Point Process Model is Multitype
is.marked.ppm

Test Whether A Point Process Model is Marked
intersect.owin

Intersection or Union of Two Windows
identify.ppp

Identify Points in a Point Pattern
print.ppm

Print a Fitted Point Process Model
Geyer

Geyer's Saturation Point Process Model
urkiola

Urkiola Woods Point Pattern
is.ppp

Test Whether An Object Is A Point Pattern
quad.object

Class of Quadrature Schemes
finpines

Pine saplings in Finland.
MultiStrauss

The Multitype Strauss Point Process Model
fasp.object

Function Arrays for Spatial Patterns
qqplot.ppm

Q-Q Plot of Residuals from Fitted Point Process Model
plot.im

Plot a Pixel Image
nbfires

Point Patterns of New Brunswick Forest Fires
quadscheme

Generate a Quadrature Scheme from a Point Pattern
rmhmodel.ppm

Interpret Fitted Model for Metropolis-Hastings Simulation.
Kdot.inhom

Inhomogeneous Multitype K Dot Function
erode.owin

Erode a Window
raster.x

Cartesian Coordinates for a Pixel Raster
Jcross

Multitype J Function (i-to-j)
trim.rectangle

Cut margins from rectangle
anova.ppm

ANOVA for Fitted Point Process Models
nndist.psp

Nearest neighbour distances between line segments
mean.im

Mean Pixel Value in an Image
expand.owin

Expand Window By Factor
is.multitype.ppp

Test Whether A Point Pattern is Multitype
spatstat-internal

Internal spatstat functions
rMaternI

Simulate Matern Model I
model.images

Compute Images of Constructed Covariates
dummy.ppm

Extract Dummy Points Used to Fit a Point Process Model
Poisson

Poisson Point Process Model
ants

Harkness-Isham ants' nests data
gridcentres

Rectangular grid of points
rmhmodel.list

Define Point Process Model for Metropolis-Hastings Simulation.
affine

Apply Affine Transformation
clickppp

Interactively Add Points
thomas.estK

Fit the Thomas Point Process by Minimum Contrast
plot.psp

plot a Spatial Line Segment Pattern
envelope

Simulation envelopes of summary function
rsyst

Simulate systematic random point pattern
nnwhich

Nearest neighbour
contour.im

Contour plot of pixel image
ppm.object

Class of Fitted Point Process Models
markcorr

Mark Correlation Function
plot.ppp

plot a Spatial Point Pattern
as.psp

Convert Data To Class psp
Kmeasure

Reduced Second Moment Measure
kppm

Fit cluster point process model
subset.ppp

Extract or Replace Subset of Point Pattern
japanesepines

Japanese Pines Point Pattern
km.rs

Kaplan-Meier and Reduced Sample Estimator using Histograms
is.im

Test Whether An Object Is A Pixel Image
betacells

Beta Ganglion Cells in Cat Retina
compatible.fv

Test Whether Two Function Objects Are Compatible
area.owin

Area of a Window
quadrat.test

Chi-Squared Dispersion Test for Spatial Point Pattern Based on Quadrat Counts
rescale

Convert dataset to another unit of length
concatxy

Concatenate x,y Coordinate Vectors
rescale.owin

Convert Window to Another Unit of Length
shift

Apply Vector Translation
simulate.kppm

Simulate a fitted cluster point process model.
Kmulti

Marked K-Function
amacrine

Hughes' Amacrine Cell Data
is.owin

Test Whether An Object Is A Window
longleaf

Longleaf Pines Point Pattern
Linhom

L-function
pairwise.family

Pairwise Interaction Process Family
crossing.psp

Crossing Points of Two Line Segment Patterns
multiplicity.ppp

Count Multiplicity of Duplicate Points
nndist

Nearest neighbour distances
persp.im

Perspective Plot of Pixel Image
mincontrast

Method of Minimum Contrast
is.multitype

Test whether Object is Multitype
rMatClust

Simulate Matern Cluster Process
setcov

Set Covariance of a Window
rmh.default

Simulate Point Process Models using the Metropolis-Hastings Algorithm.
blur

Apply Gaussian Blur to a Pixel Image
endpoints.psp

Endpoints of Line Segment Pattern
Lcross

Multitype L-function (cross-type)
complement.owin

Take Complement of a Window
vertices

Vertices of a Window
rmpoint

Generate N Random Multitype Points
rlinegrid

Generate grid of parallel lines with random displacement
owin

Create a Window
rshift.splitppp

Randomly Shift a List of Point Patterns
rGaussPoisson

Simulate Gauss-Poisson Process
matclust.estK

Fit the Matern Cluster Point Process by Minimum Contrast
selfcrossing.psp

Crossing Points in a Line Segment Pattern
rshift.psp

Randomly Shift a Line Segment Pattern
rmhmodel

Define Point Process Model for Metropolis-Hastings Simulation.
quad.ppm

Extract Quadrature Scheme Used to Fit a Point Process Model
summary.listof

Summary of a List of Things
Pairwise

Generic Pairwise Interaction model
shift.owin

Apply Vector Translation To Window
plot.owin

Plot a Spatial Window
bounding.box.xy

Convex Hull of Points
reduced.sample

Reduced Sample Estimator using Histogram Data
update.ppm

Update a Fitted Point Process Model
nztrees

New Zealand Trees Point Pattern
affine.psp

Apply Affine Transformation To Line Segment Pattern
print.quad

Print a Quadrature Scheme
rSSI

Simulate Simple Sequential Inhibition
rNeymanScott

Simulate Neyman-Scott Process
angles.psp

Orientation Angles of Line Segments
density.ppp

Kernel Smoothed Intensity of Point Pattern
copper

Berman-Huntington points and lines data
hist.im

Histogram of Pixel Values in an Image
shift.psp

Apply Vector Translation To Line Segment Pattern
summary.ppp

Summary of a Point Pattern Dataset
diagnose.ppm

Diagnostic Plots for Fitted Point Process Model
ppm

Fit Point Process Model to Data
shift.ppp

Apply Vector Translation To Point Pattern
summary.splitppp

Summary of a Split Point Pattern
kstest.ppm

Kolmogorov-Smirnov Test for Point Process Model
fitted.ppm

Fitted Conditional Intensity for Point Process Model
ganglia

Beta Ganglion Cells in Cat Retina, Old Version
summary.owin

Summary of a Spatial Window
redwoodfull

California Redwoods Point Pattern (Entire Dataset)
print.owin

Print Brief Details of a Spatial Window
rshift

Random Shift
applynbd

Apply Function to Every Neighbourhood in a Point Pattern
owin.object

Class owin
crossdist.psp

Pairwise distances between two different line segment patterns
square

Square Window
ewcdf

Weighted Empirical Cumulative Distribution Function
plot.quad

plot a Spatial Quadrature Scheme
inside.owin

Test Whether Points Are Inside A Window
plot.kppm

Plot a fitted cluster point process
plot.listof

Plot a List of Things
rMaternII

Simulate Matern Model II
letterR

Window in Shape of Letter R
rjitter

Random Perturbation of a Point Pattern
psp

Create a Line Segment Pattern
spatstat.options

Internal Options in Spatstat Package
rStrauss

Perfect Simulation of the Strauss Process
lgcp.estK

Fit a Log-Gaussian Cox Point Process by Minimum Contrast
rstrat

Simulate Stratified Random Point Pattern
profilepl

Profile Maximum Pseudolikelihood
rescale.ppp

Convert Point Pattern to Another Unit of Length
rmh.ppm

Simulate from a Fitted Point Process Model
rcell

Simulate Baddeley-Silverman Cell Process
eval.fasp

Evaluate Expression Involving Function Arrays
midpoints.psp

Midpoints of Line Segment Pattern
redwood

California Redwoods Point Pattern (Ripley's Subset)
fitin.ppm

Extract the Interaction from a Fitted Point Process Model
is.ppm

Test Whether An Object Is A Fitted Point Process Model
matchingdist

Distance for a Point Pattern Matching
kaplan.meier

Kaplan-Meier Estimator using Histogram Data
lurking

Lurking variable plot
plot.fv

Plot Function Valuesn
subset.fasp

Extract Subset of Function Array
pppdist

Distance Between Two Point Patterns
residualspaper

Data and Code From JRSS Discussion Paper on Residuals
ppp.object

Class of Point Patterns
model.matrix.ppm

Extract Design Matrix from Point Process Model
print.im

Print Brief Details of an Image
rpoint

Generate N Random Points
disc

Circular Window
rthin

Random Thinning
union.quad

Union of Data and Dummy Points
pppmatching.object

Class of Point Matchings
predict.kppm

Prediction from a Fitted Cluster Point Process Model
nncross

Nearest Neighbour in Another Point Pattern
effectfun

Compute Fitted Effect of a Spatial Covariate in a Point Process Model
unmark

Remove Marks from a Marked Point Pattern
update.kppm

Update a Fitted Cluster Point Process Model
subset.psp

Extract Subset of Line Segment Pattern
setmarks

Set or Reset the Marks in a Point Pattern
superimpose

Superimpose Several Point Patterns
subsetget.im

Reset Values in Subset of Image
rmhcontrol

Set Control Parameters for Metropolis-Hastings Algorithm.
lansing

Lansing Woods Point Pattern
runifdisc

Generate N Uniform Random Points in a Disc
inforder.family

Infinite Order Interaction Family
predict.ppm

Prediction from a Fitted Point Process Model
plot.plotppm

Plot a plotppm Object Created by plot.ppm
rotate.owin

Rotate a Window
pairdist

Pairwise distances
suffstat

Sufficient Statistic of Point Process Model
nncorr

Nearest-Neighbour Correlation of Marked Point Pattern
rThomas

Simulate Thomas Process
solutionset

Evaluate Logical Expression Involving Pixel Images and Return Region Where Expression is True
quantile.im

Sample Quantiles of Pixel Image
plot.hyperframe

Plot Entries in a Hyperframe
rmh

Simulate point patterns using the Metropolis-Hastings algorithm.
rlabel

Random Re-Labelling of Point Pattern
summary.psp

Summary of a Line Segment Pattern Dataset
print.ppp

Print Brief Details of a Point Pattern Dataset
pcf.ppp

Pair Correlation Function of Point Pattern
shift.im

Apply Vector Translation To Pixel Image
rescue.rectangle

Convert Window Back To Rectangle
with.fv

Evaluate an Expression in a Function Table
progressreport

Print Progress Reports
summary.im

Summarizing a Pixel Image
pairdist.default

Pairwise distances
subset.fv

Extract Subset of Function Values
pairsat.family

Saturated Pairwise Interaction Point Process Family
residuals.ppm

Residuals for Fitted Point Process Model
reach

Interaction Distance of a Point Process
runifpoint

Generate N Uniform Random Points
subset.listof

Extract or Replace Subset of a List of Things
rmhmodel.default

Build Point Process Model for Metropolis-Hastings Simulation.
spruces

Spruces Point Pattern
unitname

Name for Unit of Length
subset.splitppp

Extract or Replace Sub-Patterns
simdat

Simulated Point Pattern
nearest.raster.point

Find Pixel Nearest to a Given Point
smooth.ppp

Spatial smoothing of observations at irregular points
ponderosa

Ponderosa Pine Tree Point Pattern
pppmatching

Create a Point Matching
psp.object

Class of Line Segment Patterns
swedishpines

Swedish Pines Point Pattern
split.ppp

Divide Point Pattern into Sub-patterns
subset.im

Extract Subset of Image
unique.ppp

Extract Unique Points from a Spatial Point Pattern
summary.quad

Summarizing a Quadrature Scheme
summary.ppm

Summarizing a Fitted Point Process Model
vcov.ppm

Variance-Covariance Matrix for a Fitted Point Process Model