Learn R Programming

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

spatstat (version 1.14-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.14-4

License

GPL (>= 2)

Maintainer

Adrian Baddeley

Last Published

March 22nd, 2025

Functions in spatstat (1.14-4)

AreaInter

The Area Interaction Point Process Model
as.mask

Pixel Image Approximation of a Window
matchingdist

Distance for a Point Pattern Matching
chorley

Chorley-Ribble Cancer Data
ppp

Create a Point Pattern
plot.kppm

Plot a fitted cluster point process
OrdThresh

Ord's Interaction model
eval.hyper

Evaluate an Expression in Each Row of a Hyperframe
murchison

Murchison gold deposits
Saturated

Saturated Pairwise Interaction model
marktable

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

Difference of Disc Areas
Gest

Nearest Neighbour Distance Function G
quantile.im

Sample Quantiles of Pixel Image
as.rectangle

Window Frame
rMatClust

Simulate Matern Cluster Process
Kinhom

Inhomogeneous K-function
predict.ppm

Prediction from a Fitted Point Process Model
compatible.fv

Test Whether Two Function Objects Are Compatible
demopat

Artificial Data Point Pattern
persp.im

Perspective Plot of Pixel Image
copper

Berman-Huntington points and lines data
pairwise.family

Pairwise Interaction Process Family
rmhstart

Determine Initial State for Metropolis-Hastings Simulation.
rescale.im

Convert Pixel Image to Another Unit of Length
adaptive.density

Intensity Estimate of Point Pattern Using Tessellation
distmap.psp

Distance Map of Line Segment Pattern
applynbd

Apply Function to Every Neighbourhood in a Point Pattern
Kmeasure

Reduced Second Moment Measure
effectfun

Compute Fitted Effect of a Spatial Covariate in a Point Process Model
psp.object

Class of Line Segment Patterns
MultiStraussHard

The Multitype/Hard Core Strauss Point Process Model
km.rs

Kaplan-Meier and Reduced Sample Estimator using Histograms
density.ppp

Kernel Smoothed Intensity of Point Pattern
lengths.psp

Lengths of Line Segments
density.psp

Kernel Smoothing of Line Segment Pattern
is.multitype.ppp

Test Whether A Point Pattern is Multitype
Jest

Estimate the J-function
affine

Apply Affine Transformation
by.ppp

Apply a Function to a Point Pattern Broken Down by Factor
owin.object

Class owin
as.im

Convert to Pixel Image
Poisson

Poisson Point Process Model
Linhom

L-function
StraussHard

The Strauss / Hard Core Point Process Model
clickpoly

Interactively Define a Polygon
cut.im

Convert Pixel Image from Numeric to Factor
bei

Tropical rain forest trees
Kmulti

Marked K-Function
multiplicity.ppp

Count Multiplicity of Duplicate Points
anova.ppm

ANOVA for Fitted Point Process Models
with.fv

Evaluate an Expression in a Function Table
letterR

Window in Shape of Letter R
rlabel

Random Re-Labelling of Point Pattern
Softcore

The Soft Core Point Process Model
nbfires

Point Patterns of New Brunswick Forest Fires
allstats

Calculate four standard summary functions of a point pattern.
Kest

K-function
rmhmodel.default

Build Point Process Model for Metropolis-Hastings Simulation.
affine.ppp

Apply Affine Transformation To Point Pattern
ants

Harkness-Isham ants' nests data
print.im

Print Brief Details of an Image
blur

Apply Gaussian Blur to a Pixel Image
erode.owin

Erode a Window
Kest.fft

K-function using FFT
distmap.owin

Distance Map of Window
as.ppp

Convert Data To Class ppp
crossdist

Pairwise distances
Geyer

Geyer's Saturation Point Process Model
fasp.object

Function Arrays for Spatial Patterns
anemones

Beadlet Anemones Data
cut.ppp

Classify Points in a Point Pattern
gridcentres

Rectangular grid of points
Kcross.inhom

Inhomogeneous Cross K Function
spatstat-internal

Internal spatstat functions
diagnose.ppm

Diagnostic Plots for Fitted Point Process Model
as.matrix.im

Convert Pixel Image to Matrix
plot.ppp

plot a Spatial Point Pattern
bdist.pixels

Distance to Boundary of Window
finpines

Pine saplings in Finland.
convexhull.xy

Convex Hull of Points
dirichlet.weights

Compute Quadrature Weights Based on Dirichlet Tessellation
delaunay

Delaunay Triangulation of Point Pattern
discretise

Safely Convert Point Pattern Window to Binary Mask
quadscheme

Generate a Quadrature Scheme from a Point Pattern
dummy.ppm

Extract Dummy Points Used to Fit a Point Process Model
is.marked.ppp

Test Whether A Point Pattern is Marked
distmap.ppp

Distance Map of Point Pattern
ord.family

Ord Interaction Process Family
print.ppm

Print a Fitted Point Process Model
is.owin

Test Whether An Object Is A Window
rescale

Convert dataset to another unit of length
hist.im

Histogram of Pixel Values in an Image
crossing.psp

Crossing Points of Two Line Segment Patterns
corners

Corners of a rectangle
reduced.sample

Reduced Sample Estimator using Histogram Data
residuals.ppm

Residuals for Fitted Point Process Model
plot.fasp

Plot a Function Array
concatxy

Concatenate x,y Coordinate Vectors
diameter

Diameter of a Window
Kdot.inhom

Inhomogeneous Multitype K Dot Function
plot.psp

plot a Spatial Line Segment Pattern
Lcross

Multitype L-function (cross-type)
endpoints.psp

Endpoints of Line Segment Pattern
PairPiece

The Piecewise Constant Pairwise Interaction Point Process Model
model.matrix.ppm

Extract Design Matrix from Point Process Model
pcf

Pair Correlation Function
quadrats

Divide Region into Quadrats
default.dummy

Generate a Default Pattern of Dummy Points
ganglia

Beta Ganglion Cells in Cat Retina, Old Version
rGaussPoisson

Simulate Gauss-Poisson Process
print.ppp

Print Brief Details of a Point Pattern Dataset
Fest

Estimate the empty space function F
pppdist

Distance Between Two Point Patterns
pcfcross

Multitype pair correlation function
pairsat.family

Saturated Pairwise Interaction Point Process Family
rsyst

Simulate systematic random point pattern
is.im

Test Whether An Object Is A Pixel Image
clickppp

Interactively Add Points
Kdot

Multitype K Function (i-to-any)
lgcp.estK

Fit a Log-Gaussian Cox Point Process by Minimum Contrast
crossdist.default

Pairwise distances between two different sets of points
SatPiece

Piecewise Constant Saturated Pairwise Interaction Point Process Model
rmhmodel.ppm

Interpret Fitted Model for Metropolis-Hastings Simulation.
rNeymanScott

Simulate Neyman-Scott Process
levelset

Level Set of a Pixel Image
hyperframe

Hyper Data Frame
fitin.ppm

Extract the Interaction from a Fitted Point Process Model
Gmulti

Marked Nearest Neighbour Distance Function
envelope

Simulation envelopes of summary function
dirichlet

Dirichlet Tessellation of Point Pattern
Jmulti

Marked J Function
is.marked

Test Whether Marks Are Present
disc

Circular Window
identify.ppp

Identify Points in a Point Pattern
interp.im

Interpolate a Pixel Image
longleaf

Longleaf Pines Point Pattern
quadratcount

Quadrat counting for a point pattern
markcorr

Mark Correlation Function
Ldot

Multitype L-function (i-to-any)
midpoints.psp

Midpoints of Line Segment Pattern
as.data.frame.ppp

Coerce Point Pattern to a Data Frame
quadratresample

Resample a Point Pattern by Resampling Quadrats
rshift.ppp

Randomly Shift a Point Pattern
DiggleGratton

Diggle-Gratton model
nearest.raster.point

Find Pixel Nearest to a Given Point
rpoispp

Generate Poisson Point Pattern
by.im

Apply Function to Image Broken Down by Factor
Lest

L-function
Kcross

Multitype K Function (Cross-type)
is.subset.owin

Determine Whether One Window is Contained In Another
Gdot

Multitype Nearest Neighbour Distance Function (i-to-any)
duplicated.ppp

Determine Duplicated Points in a Spatial Point Pattern
angles.psp

Orientation Angles of Line Segments
pcf.fv

Pair Correlation Function obtained from K Function
nnwhich

Nearest neighbour
data.ppm

Extract Original Data from a Fitted Point Process Model
lurking

Lurking variable plot
bdist.points

Distance to Boundary of Window
model.images

Compute Images of Constructed Covariates
shift

Apply Vector Translation
split.im

Divide Image Into Sub-images
eval.fasp

Evaluate Expression Involving Function Arrays
cells

Biological Cells Point Pattern
summary.psp

Summary of a Line Segment Pattern Dataset
runifdisc

Generate N Uniform Random Points in a Disc
crossdist.ppp

Pairwise distances between two different point patterns
MultiStrauss

The Multitype Strauss Point Process Model
ponderosa

Ponderosa Pine Tree Point Pattern
logLik.ppm

Log Likelihood for Poisson Point Process Model
Pairwise

Generic Pairwise Interaction model
dilate.owin

Dilate a Window
Ord

Generic Ord Interaction model
eval.fv

Evaluate Expression Involving Functions
affine.psp

Apply Affine Transformation To Line Segment Pattern
rotate

Rotate
intersect.owin

Intersection or Union of Two Windows
Strauss

The Strauss Point Process Model
pppmatching.object

Class of Point Matchings
rmpoispp

Generate Multitype Poisson Point Pattern
subset.im

Extract Subset of Image
subset.psp

Extract Subset of Line Segment Pattern
subset.splitppp

Extract or Replace Sub-Patterns
rescale.ppp

Convert Point Pattern to Another Unit of Length
nncorr

Nearest-Neighbour Correlation of Marked Point Pattern
im.object

Class of Images
fv.object

Data Frames of Function Values
plot.plotppm

Plot a plotppm Object Created by plot.ppm
summary.splitppp

Summary of a Split Point Pattern
clarkevans

Clark and Evans Aggregation Index
solutionset

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

Hutchings' Bramble Canes data
hamster

Aherne's hamster tumour data
quad.ppm

Extract Quadrature Scheme Used to Fit a Point Process Model
nndist.psp

Nearest neighbour distances between line segments
Gcross

Multitype Nearest Neighbour Distance Function (i-to-j)
is.ppp

Test Whether An Object Is A Point Pattern
pixelquad

Quadrature Scheme Based on Pixel Grid
plot.im

Plot a Pixel Image
area.owin

Area of a Window
plot.splitppp

Plot a List of Point Patterns
unmark

Remove Marks from a Marked Point Pattern
is.multitype.ppm

Test Whether A Point Process Model is Multitype
harmonic

Basis for Harmonic Functions
Jdot

Multitype J Function (i-to-any)
quad.object

Class of Quadrature Schemes
is.ppm

Test Whether An Object Is A Fitted Point Process Model
as.owin

Convert Data To Class owin
progressreport

Print Progress Reports
lansing

Lansing Woods Point Pattern
BadGey

Hybrid Geyer Point Process Model
rshift.psp

Randomly Shift a Line Segment Pattern
rotate.ppp

Rotate a Point Pattern
bounding.box

Bounding Box of a Window or Point Pattern
ppm

Fit Point Process Model to Data
distmap

Distance Map
ripras

Estimate window from points alone
rjitter

Random Perturbation of a Point Pattern
inside.owin

Test Whether Points Are Inside A Window
gpc2owin

Convert Polygonal Region into Different Format
vcov.ppm

Variance-Covariance Matrix for a Fitted Point Process Model
spatstat

The Spatstat Package
expand.owin

Expand Window By Factor
nncross

Nearest Neighbour in Another Point Pattern
localK

Neighbourhood density function
rSSI

Simulate Simple Sequential Inhibition
alltypes

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

Vertices of a Window
Iest

Estimate the I-function
mean.im

Mean, Median and Range of Pixel Values in an Image
Jcross

Multitype J Function (i-to-j)
LennardJones

The Lennard-Jones Potential
nztrees

New Zealand Trees Point Pattern
nndist

Nearest neighbour distances
rmh.ppm

Simulate from a Fitted Point Process Model
append.psp

Combine Two Line Segment Patterns
betacells

Beta Ganglion Cells in Cat Retina
incircle

Find Largest Circle Inside Window
bounding.box.xy

Convex Hull of Points
rmhcontrol

Set Control Parameters for Metropolis-Hastings Algorithm.
as.psp

Convert Data To Class psp
density.splitppp

Kernel Smoothed Intensity of Split Point Pattern
rmpoint

Generate N Random Multitype Points
ppp.object

Class of Point Patterns
eroded.areas

Areas of Morphological Erosions
print.psp

Print Brief Details of a Line Segment Pattern Dataset
markstat

Summarise Marks in Every Neighbourhood in a Point Pattern
amacrine

Hughes' Amacrine Cell Data
centroid.owin

Centroid of a window
rpoint

Generate N Random Points
compatible.fasp

Test Whether Two Function Arrays Are Compatible
compatible.im

Test Whether Two Pixel Images Are Compatible
japanesepines

Japanese Pines Point Pattern
contour.im

Contour plot of pixel image
rthin

Random Thinning
pcf.ppp

Pair Correlation Function of Point Pattern
reach

Interaction Distance of a Point Process
plot.listof

Plot a List of Things
coef.ppm

Coefficients of Fitted Point Process Model
rpoisline

Generate Poisson Random Line Process
ewcdf

Weighted Empirical Cumulative Distribution Function
rmhmodel

Define Point Process Model for Metropolis-Hastings Simulation.
redwood

California Redwoods Point Pattern (Ripley's Subset)
shift.psp

Apply Vector Translation To Line Segment Pattern
[.tess

Extract or Replace Subset of Tessellation
setcov

Set Covariance of a Window
rmh

Simulate point patterns using the Metropolis-Hastings algorithm.
plot.tess

Plot a tessellation
selfcrossing.psp

Crossing Points in a Line Segment Pattern
eval.im

Evaluate Expression Involving Pixel Images
pairdist

Pairwise distances
owin

Create a Window
matclust.estK

Fit the Matern Cluster Point Process by Minimum Contrast
print.quad

Print a Quadrature Scheme
pairdist.psp

Pairwise distances between line segments
superimpose

Superimpose Several Point Patterns
plot.owin

Plot a Spatial Window
is.multitype

Test whether Object is Multitype
rMaternII

Simulate Matern Model II
spruces

Spruces Point Pattern
rotate.owin

Rotate a Window
shift.im

Apply Vector Translation To Pixel Image
redwoodfull

California Redwoods Point Pattern (Entire Dataset)
profilepl

Profile Maximum Pseudolikelihood
[.quad

Subset of Quadrature Scheme
setmarks

Set or Reset the Marks in a Point Pattern
pppmatching

Create a Point Matching
rThomas

Simulate Thomas Process
fitted.ppm

Fitted Conditional Intensity for Point Process Model
inforder.family

Infinite Order Interaction Family
rescale.psp

Convert Line Segment Pattern to Another Unit of Length
pairdist.default

Pairwise distances
pcf.fasp

Pair Correlation Function obtained from array of K functions
trim.rectangle

Cut margins from rectangle
kaplan.meier

Kaplan-Meier Estimator using Histogram Data
rstrat

Simulate Stratified Random Point Pattern
rescue.rectangle

Convert Window Back To Rectangle
rescale.owin

Convert Window to Another Unit of Length
plot.ppm

plot a Fitted Point Process Model
runifpoint

Generate N Uniform Random Points
mincontrast

Method of Minimum Contrast
plot.quad

plot a Spatial Quadrature Scheme
eem

Exponential Energy Marks
square

Square Window
affine.owin

Apply Affine Transformation To Window
psp

Create a Line Segment Pattern
shift.owin

Apply Vector Translation To Window
print.owin

Print Brief Details of a Spatial Window
gridweights

Compute Quadrature Weights Based on Grid Counts
is.marked.ppm

Test Whether A Point Process Model is Marked
spatstat.options

Internal Options in Spatstat Package
kppm

Fit cluster point process model
update.kppm

Update a Fitted Cluster Point Process Model
summary.owin

Summary of a Spatial Window
subset.fv

Extract Subset of Function Values
im

Create a Pixel Image Object
suffstat

Sufficient Statistic of Point Process Model
summary.ppm

Summarizing a Fitted Point Process Model
rmh.default

Simulate Point Process Models using the Metropolis-Hastings Algorithm.
complement.owin

Take Complement of a Window
update.ppm

Update a Fitted Point Process Model
unitname

Name for Unit of Length
crossdist.psp

Pairwise distances between two different line segment patterns
urkiola

Urkiola Woods Point Pattern
plot.fv

Plot Function Valuesn
split.ppp

Divide Point Pattern into Sub-patterns
subset.listof

Extract or Replace Subset of a List of Things
spatstat-deprecated

Deprecated spatstat functions
rmhmodel.list

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

Class of Fitted Point Process Models
rlinegrid

Generate grid of parallel lines with random displacement
rMaternI

Simulate Matern Model I
summary.listof

Summary of a List of Things
subset.fasp

Extract Subset of Function Array
shift.ppp

Apply Vector Translation To Point Pattern
swedishpines

Swedish Pines Point Pattern
rStrauss

Perfect Simulation of the Strauss Process
raster.x

Cartesian Coordinates for a Pixel Raster
smooth.ppp

Spatial smoothing of observations at irregular points
humberside

Humberside Data on Childhood Leukaemia and Lymphoma
unique.ppp

Extract Unique Points from a Spatial Point Pattern
union.quad

Union of Data and Dummy Points
residualspaper

Data and Code From JRSS Discussion Paper on Residuals
kstest.ppm

Kolmogorov-Smirnov Test for Point Process Model
pairdist.ppp

Pairwise distances
rotate.psp

Rotate a Line Segment Pattern
stieltjes

Compute Integral of Function Against Cumulative Distribution
predict.kppm

Prediction from a Fitted Cluster Point Process Model
qqplot.ppm

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

Plot Entries in a Hyperframe
simulate.kppm

Simulate a fitted cluster point process model.
summary.ppp

Summary of a Point Pattern Dataset
spokes

Spokes pattern of dummy points
quadrat.test

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

Create a Tessellation
rcell

Simulate Baddeley-Silverman Cell Process
rshift

Random Shift
scanpp

Read Point Pattern From Data File
rshift.splitppp

Randomly Shift a List of Point Patterns
simdat

Simulated Point Pattern
subset.ppp

Extract or Replace Subset of Point Pattern
summary.im

Summarizing a Pixel Image
thomas.estK

Fit the Thomas Point Process by Minimum Contrast
subsetget.im

Reset Values in Subset of Image
tiles

Extract List of Tiles in a Tessellation
summary.quad

Summarizing a Quadrature Scheme