Learn R Programming

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

spatstat (version 1.14-0)

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

22,386

Version

1.14-0

License

GPL (>= 2)

Maintainer

Adrian Baddeley

Last Published

February 1st, 2026

Functions in spatstat (1.14-0)

clickpoly

Interactively Define a Polygon
OrdThresh

Ord's Interaction model
by.ppp

Apply a Function to a Point Pattern Broken Down by Factor
copper

Berman-Huntington points and lines data
bei

Tropical rain forest trees
MultiStraussHard

The Multitype/Hard Core Strauss Point Process Model
anemones

Beadlet Anemones Data
Kest

K-function
ponderosa

Ponderosa Pine Tree Point Pattern
diameter

Diameter of a Window
clarkevans

Clark and Evans Aggregation Index
ants

Harkness-Isham ants' nests data
Gest

Nearest Neighbour Distance Function G
dummy.ppm

Extract Dummy Points Used to Fit a Point Process Model
crossdist.default

Pairwise distances between two different sets of points
eval.im

Evaluate Expression Involving Pixel Images
distmap.owin

Distance Map of Window
spatstat

The Spatstat Package
spatstat-deprecated

Deprecated spatstat functions
alltypes

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

L-function
levelset

Level Set of a Pixel Image
as.rectangle

Window Frame
kppm

Fit cluster point process model
default.dummy

Generate a Default Pattern of Dummy Points
distmap.ppp

Distance Map of Point Pattern
nncorr

Nearest-Neighbour Correlation of Marked Point Pattern
chorley

Chorley-Ribble Cancer Data
LennardJones

The Lennard-Jones Potential
distmap

Distance Map
crossdist.psp

Pairwise distances between two different line segment patterns
angles.psp

Orientation Angles of Line Segments
bramblecanes

Hutchings' Bramble Canes data
Saturated

Saturated Pairwise Interaction model
Kmeasure

Reduced Second Moment Measure
Jmulti

Marked J Function
duplicated.ppp

Determine Duplicated Points in a Spatial Point Pattern
concatxy

Concatenate x,y Coordinate Vectors
print.owin

Print Brief Details of a Spatial Window
as.mask

Pixel Image Approximation of a Window
Kdot

Multitype K Function (i-to-any)
plot.quad

plot a Spatial Quadrature Scheme
bounding.box.xy

Convex Hull of Points
applynbd

Apply Function to Every Neighbourhood in a Point Pattern
BadGey

Hybrid Geyer Point Process Model
Fest

Estimate the empty space function F
ewcdf

Weighted Empirical Cumulative Distribution Function
cut.ppp

Classify Points in a Point Pattern
pairwise.family

Pairwise Interaction Process Family
crossdist

Pairwise distances
Geyer

Geyer's Saturation Point Process Model
Gcross

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

Nearest neighbour
identify.ppp

Identify Points in a Point Pattern
density.psp

Kernel Smoothing of Line Segment Pattern
Jdot

Multitype J Function (i-to-any)
intersect.owin

Intersection or Union of Two Windows
quad.object

Class of Quadrature Schemes
density.splitppp

Kernel Smoothed Intensity of Split Point Pattern
data.ppm

Extract Original Data from a Fitted Point Process Model
compatible.fv

Test Whether Two Function Objects Are Compatible
ganglia

Beta Ganglion Cells in Cat Retina, Old Version
as.matrix.im

Convert Pixel Image to Matrix
pairdist.ppp

Pairwise distances
matclust.estK

Fit the Matern Cluster Point Process by Minimum Contrast
predict.kppm

Prediction from a Fitted Cluster Point Process Model
is.im

Test Whether An Object Is A Pixel Image
km.rs

Kaplan-Meier and Reduced Sample Estimator using Histograms
localK

Neighbourhood density function
as.ppp

Convert Data To Class ppp
expand.owin

Expand Window By Factor
compatible.im

Test Whether Two Pixel Images Are Compatible
print.ppp

Print Brief Details of a Point Pattern Dataset
hamster

Aherne's hamster tumour data
mean.im

Mean Pixel Value in an Image
AreaInter

The Area Interaction Point Process Model
bounding.box

Bounding Box of a Window or Point Pattern
append.psp

Combine Two Line Segment Patterns
erode.owin

Erode a Window
clickppp

Interactively Add Points
hist.im

Histogram of Pixel Values in an Image
Kinhom

Inhomogeneous K-function
centroid.owin

Centroid of a window
is.multitype.ppm

Test Whether A Point Process Model is Multitype
japanesepines

Japanese Pines Point Pattern
plot.psp

plot a Spatial Line Segment Pattern
area.owin

Area of a Window
pairdist.psp

Pairwise distances between line segments
plot.fasp

Plot a Function Array
Ldot

Multitype L-function (i-to-any)
density.ppp

Kernel Smoothed Intensity of Point Pattern
blur

Apply Gaussian Blur to a Pixel Image
eval.hyper

Evaluate an Expression in Each Row of a Hyperframe
psp

Create a Line Segment Pattern
lgcp.estK

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

Generate N Uniform Random Points
bdist.points

Distance to Boundary of Window
areadiff

Difference of Disc Areas
nncross

Nearest Neighbour in Another Point Pattern
inforder.family

Infinite Order Interaction Family
kstest.ppm

Kolmogorov-Smirnov Test for Point Process Model
demopat

Artificial Data Point Pattern
as.psp

Convert Data To Class psp
gpc2owin

Convert Polygonal Region into Different Format
spruces

Spruces Point Pattern
Poisson

Poisson Point Process Model
Iest

Estimate the I-function
Lest

L-function
lurking

Lurking variable plot
discretise

Safely Convert Point Pattern Window to Binary Mask
finpines

Pine saplings in Finland.
eval.fasp

Evaluate Expression Involving Function Arrays
Kcross

Multitype K Function (Cross-type)
multiplicity.ppp

Count Multiplicity of Duplicate Points
lansing

Lansing Woods Point Pattern
Kcross.inhom

Inhomogeneous Cross K Function
pcf.fasp

Pair Correlation Function obtained from array of K functions
model.matrix.ppm

Extract Design Matrix from Point Process Model
affine.owin

Apply Affine Transformation To Window
affine.ppp

Apply Affine Transformation To Point Pattern
amacrine

Hughes' Amacrine Cell Data
pcf

Pair Correlation Function
SatPiece

Piecewise Constant Saturated Pairwise Interaction Point Process Model
plot.tess

Plot a tessellation
logLik.ppm

Log Likelihood for Poisson Point Process Model
ppm.object

Class of Fitted Point Process Models
spokes

Spokes pattern of dummy points
fasp.object

Function Arrays for Spatial Patterns
plot.hyperframe

Plot Entries in a Hyperframe
convexhull.xy

Convex Hull of Points
Kmulti

Marked K-Function
interp.im

Interpolate a Pixel Image
dilate.owin

Dilate a Window
diagnose.ppm

Diagnostic Plots for Fitted Point Process Model
affine.psp

Apply Affine Transformation To Line Segment Pattern
model.images

Compute Images of Constructed Covariates
print.psp

Print Brief Details of a Line Segment Pattern Dataset
as.data.frame.ppp

Coerce Point Pattern to a Data Frame
summary.quad

Summarizing a Quadrature Scheme
psp.object

Class of Line Segment Patterns
ppp.object

Class of Point Patterns
is.ppp

Test Whether An Object Is A Point Pattern
crossing.psp

Crossing Points of Two Line Segment Patterns
quadscheme

Generate a Quadrature Scheme from a Point Pattern
rotate.owin

Rotate a Window
rmhmodel.list

Define Point Process Model for Metropolis-Hastings Simulation.
pppdist

Distance Between Two Point Patterns
predict.ppm

Prediction from a Fitted Point Process Model
fv.object

Data Frames of Function Values
pppmatching.object

Class of Point Matchings
rotate.psp

Rotate a Line Segment Pattern
print.quad

Print a Quadrature Scheme
print.im

Print Brief Details of an Image
rMatClust

Simulate Matern Cluster Process
is.ppm

Test Whether An Object Is A Fitted Point Process Model
summary.ppm

Summarizing a Fitted Point Process Model
Jcross

Multitype J Function (i-to-j)
plot.ppm

plot a Fitted Point Process Model
owin.object

Class owin
im

Create a Pixel Image Object
qqplot.ppm

Q-Q Plot of Residuals from Fitted Point Process Model
eem

Exponential Energy Marks
letterR

Window in Shape of Letter R
subset.im

Extract Subset of Image
profilepl

Profile Maximum Pseudolikelihood
simulate.kppm

Simulate a fitted cluster point process model.
progressreport

Print Progress Reports
nearest.raster.point

Find Pixel Nearest to a Given Point
rmh.ppm

Simulate from a Fitted Point Process Model
shift.psp

Apply Vector Translation To Line Segment Pattern
as.owin

Convert Data To Class owin
nndist

Nearest neighbour distances
coef.ppm

Coefficients of Fitted Point Process Model
is.multitype

Test whether Object is Multitype
pppmatching

Create a Point Matching
setcov

Set Covariance of a Window
rotate.ppp

Rotate a Point Pattern
summary.im

Summarizing a Pixel Image
gridweights

Compute Quadrature Weights Based on Grid Counts
bdist.pixels

Distance to Boundary of Window
cut.im

Convert Pixel Image from Numeric to Factor
trim.rectangle

Cut margins from rectangle
Kdot.inhom

Inhomogeneous Multitype K Dot Function
smooth.ppp

Spatial smoothing of observations at irregular points
ord.family

Ord Interaction Process Family
Softcore

The Soft Core Point Process Model
shift.ppp

Apply Vector Translation To Point Pattern
corners

Corners of a rectangle
Strauss

The Strauss Point Process Model
rthin

Random Thinning
rNeymanScott

Simulate Neyman-Scott Process
spatstat-internal

Internal spatstat functions
plot.listof

Plot a List of Things
ppp

Create a Point Pattern
compatible.fasp

Test Whether Two Function Arrays Are Compatible
MultiStrauss

The Multitype Strauss Point Process Model
owin

Create a Window
nztrees

New Zealand Trees Point Pattern
vertices

Vertices of a Window
eval.fv

Evaluate Expression Involving Functions
marktable

Tabulate Marks in Neighbourhood of Every Point in a Point Pattern
tiles

Extract List of Tiles in a Tessellation
rmhmodel.ppm

Interpret Fitted Model for Metropolis-Hastings Simulation.
quadrat.test

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

The Piecewise Constant Pairwise Interaction Point Process Model
effectfun

Compute Fitted Effect of a Spatial Covariate in a Point Process Model
plot.ppp

plot a Spatial Point Pattern
Pairwise

Generic Pairwise Interaction model
rstrat

Simulate Stratified Random Point Pattern
pairsat.family

Saturated Pairwise Interaction Point Process Family
distmap.psp

Distance Map of Line Segment Pattern
rmpoint

Generate N Random Multitype Points
Ord

Generic Ord Interaction model
plot.fv

Plot Function Valuesn
subset.splitppp

Extract or Replace Sub-Patterns
is.marked

Test Whether Marks Are Present
residuals.ppm

Residuals for Fitted Point Process Model
Jest

Estimate the J-function
eroded.areas

Areas of Morphological Erosions
split.ppp

Divide Point Pattern into Sub-patterns
reduced.sample

Reduced Sample Estimator using Histogram Data
affine

Apply Affine Transformation
shift.im

Apply Vector Translation To Pixel Image
cells

Biological Cells Point Pattern
fitin.ppm

Extract the Interaction from a Fitted Point Process Model
reach

Interaction Distance of a Point Process
rshift.splitppp

Randomly Shift a List of Point Patterns
pairdist.default

Pairwise distances
as.im

Convert to Pixel Image
complement.owin

Take Complement of a Window
is.marked.ppm

Test Whether A Point Process Model is Marked
dirichlet.weights

Compute Quadrature Weights Based on Dirichlet Tessellation
crossdist.ppp

Pairwise distances between two different point patterns
fitted.ppm

Fitted Conditional Intensity for Point Process Model
print.ppm

Print a Fitted Point Process Model
quantile.im

Sample Quantiles of Pixel Image
plot.plotppm

Plot a plotppm Object Created by plot.ppm
union.quad

Union of Data and Dummy Points
betacells

Beta Ganglion Cells in Cat Retina
summary.ppp

Summary of a Point Pattern Dataset
Gdot

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

Method of Minimum Contrast
rThomas

Simulate Thomas Process
rshift

Random Shift
stieltjes

Compute Integral of Function Against Cumulative Distribution
rmhstart

Determine Initial State for Metropolis-Hastings Simulation.
envelope

Simulation envelopes of summary function
runifdisc

Generate N Uniform Random Points in a Disc
setmarks

Set or Reset the Marks in a Point Pattern
redwoodfull

California Redwoods Point Pattern (Entire Dataset)
rmhmodel.default

Build Point Process Model for Metropolis-Hastings Simulation.
summary.listof

Summary of a List of Things
rshift.ppp

Randomly Shift a Point Pattern
simdat

Simulated Point Pattern
kaplan.meier

Kaplan-Meier Estimator using Histogram Data
rescale.ppp

Convert Point Pattern to Another Unit of Length
Lcross

Multitype L-function (cross-type)
solutionset

Evaluate Logical Expression Involving Pixel Images and Return Region Where Expression is True
longleaf

Longleaf Pines Point Pattern
[.tess

Extract or Replace Subset of Tessellation
summary.psp

Summary of a Line Segment Pattern Dataset
rescale.psp

Convert Line Segment Pattern to Another Unit of Length
persp.im

Perspective Plot of Pixel Image
plot.im

Plot a Pixel Image
markcorr

Mark Correlation Function
rpoispp

Generate Poisson Point Pattern
is.owin

Test Whether An Object Is A Window
square

Square Window
endpoints.psp

Endpoints of Line Segment Pattern
subset.fasp

Extract Subset of Function Array
contour.im

Contour plot of pixel image
StraussHard

The Strauss / Hard Core Point Process Model
rSSI

Simulate Simple Sequential Inhibition
DiggleGratton

Diggle-Gratton model
rmhcontrol

Set Control Parameters for Metropolis-Hastings Algorithm.
rGaussPoisson

Simulate Gauss-Poisson Process
rmh

Simulate point patterns using the Metropolis-Hastings algorithm.
is.subset.owin

Determine Whether One Window is Contained In Another
anova.ppm

ANOVA for Fitted Point Process Models
rpoint

Generate N Random Points
update.kppm

Update a Fitted Cluster Point Process Model
swedishpines

Swedish Pines Point Pattern
update.ppm

Update a Fitted Point Process Model
rmpoispp

Generate Multitype Poisson Point Pattern
superimpose

Superimpose Several Point Patterns
matchingdist

Distance for a Point Pattern Matching
ripras

Estimate window from points alone
rlinegrid

Generate grid of parallel lines with random displacement
markstat

Summarise Marks in Every Neighbourhood in a Point Pattern
lengths.psp

Lengths of Line Segments
quad.ppm

Extract Quadrature Scheme Used to Fit a Point Process Model
gridcentres

Rectangular grid of points
im.object

Class of Images
rlabel

Random Re-Labelling of Point Pattern
unmark

Remove Marks from a Marked Point Pattern
allstats

Calculate four standard summary functions of a point pattern.
inside.owin

Test Whether Points Are Inside A Window
redwood

California Redwoods Point Pattern (Ripley's Subset)
disc

Circular Window
thomas.estK

Fit the Thomas Point Process by Minimum Contrast
midpoints.psp

Midpoints of Line Segment Pattern
shift.owin

Apply Vector Translation To Window
rescale

Convert dataset to another unit of length
rMaternI

Simulate Matern Model I
plot.splitppp

Plot a List of Point Patterns
summary.owin

Summary of a Spatial Window
Kest.fft

K-function using FFT
rescale.owin

Convert Window to Another Unit of Length
rsyst

Simulate systematic random point pattern
rshift.psp

Randomly Shift a Line Segment Pattern
rcell

Simulate Baddeley-Silverman Cell Process
subset.ppp

Extract or Replace Subset of Point Pattern
quadratcount

Quadrat counting for a point pattern
suffstat

Sufficient Statistic of Point Process Model
spatstat.options

Internal Options in Spatstat Package
scanpp

Read Point Pattern From Data File
rStrauss

Perfect Simulation of the Strauss Process
raster.x

Cartesian Coordinates for a Pixel Raster
dirichlet

Dirichlet Tessellation of Point Pattern
subset.psp

Extract Subset of Line Segment Pattern
ppm

Fit Point Process Model to Data
rpoisline

Generate Poisson Random Line Process
selfcrossing.psp

Crossing Points in a Line Segment Pattern
nbfires

Point Patterns of New Brunswick Forest Fires
subset.listof

Extract or Replace Subset of a List of Things
tess

Create a Tessellation
rescue.rectangle

Convert Window Back To Rectangle
humberside

Humberside Data on Childhood Leukaemia and Lymphoma
rmhmodel

Define Point Process Model for Metropolis-Hastings Simulation.
hyperframe

Hyper Data Frame
with.fv

Evaluate an Expression in a Function Table
nndist.psp

Nearest neighbour distances between line segments
plot.kppm

Plot a fitted cluster point process
residualspaper

Data and Code From JRSS Discussion Paper on Residuals
rMaternII

Simulate Matern Model II
pairdist

Pairwise distances
subsetget.im

Reset Values in Subset of Image
rotate

Rotate
urkiola

Urkiola Woods Point Pattern
unitname

Name for Unit of Length
rmh.default

Simulate Point Process Models using the Metropolis-Hastings Algorithm.
is.marked.ppp

Test Whether A Point Pattern is Marked
pcf.fv

Pair Correlation Function obtained from K Function
plot.owin

Plot a Spatial Window
pcf.ppp

Pair Correlation Function of Point Pattern
Gmulti

Marked Nearest Neighbour Distance Function
is.multitype.ppp

Test Whether A Point Pattern is Multitype
subset.fv

Extract Subset of Function Values
vcov.ppm

Variance-Covariance Matrix for a Fitted Point Process Model
shift

Apply Vector Translation
unique.ppp

Extract Unique Points from a Spatial Point Pattern
harmonic

Basis for Harmonic Functions
rjitter

Random Perturbation of a Point Pattern
summary.splitppp

Summary of a Split Point Pattern