Learn R Programming

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

spatstat (version 1.15-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

16,015

Version

1.15-0

License

GPL (>= 2)

Maintainer

Adrian Baddeley

Last Published

March 22nd, 2025

Functions in spatstat (1.15-0)

expand.owin

Expand Window By Factor
lansing

Lansing Woods Point Pattern
diameter

Diameter of a Window
murchison

Murchison gold deposits
rThomas

Simulate Thomas Process
cut.im

Convert Pixel Image from Numeric to Factor
plot.hyperframe

Plot Entries in a Hyperframe
fasp.object

Function Arrays for Spatial Patterns
plot.colourmap

Plot a Colour Map
logLik.ppm

Log Likelihood for Poisson Point Process Model
mincontrast

Method of Minimum Contrast
intersect.owin

Intersection or Union of Two Windows
plot.owin

Plot a Spatial Window
pixelquad

Quadrature Scheme Based on Pixel Grid
rotate

Rotate
disc

Circular Window
rmhmodel

Define Point Process Model for Metropolis-Hastings Simulation.
summary.psp

Summary of a Line Segment Pattern Dataset
rMaternII

Simulate Matern Model II
unique.ppp

Extract Unique Points from a Spatial Point Pattern
superimpose

Superimpose Several Point Patterns
rmh

Simulate point patterns using the Metropolis-Hastings algorithm.
square

Square Window
print.owin

Print Brief Details of a Spatial Window
union.quad

Union of Data and Dummy Points
rescale.ppp

Convert Point Pattern to Another Unit of Length
Ord

Generic Ord Interaction model
redwood

California Redwoods Point Pattern (Ripley's Subset)
rotate.ppp

Rotate a Point Pattern
spokes

Spokes pattern of dummy points
is.marked.ppm

Test Whether A Point Process Model is Marked
rStrauss

Perfect Simulation of the Strauss Process
residualspaper

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

Identify Points in a Point Pattern
owin

Create a Window
spatstat.options

Internal Options in Spatstat Package
Lest

L-function
rGaussPoisson

Simulate Gauss-Poisson Process
longleaf

Longleaf Pines Point Pattern
rotate.psp

Rotate a Line Segment Pattern
pcfcross

Multitype pair correlation function
concatxy

Concatenate x,y Coordinate Vectors
default.dummy

Generate a Default Pattern of Dummy Points
markcorr

Mark Correlation Function
plot.ppm

plot a Fitted Point Process Model
spatstat-deprecated

Deprecated spatstat functions
quadratresample

Resample a Point Pattern by Resampling Quadrats
lengths.psp

Lengths of Line Segments
corners

Corners of a rectangle
ppp

Create a Point Pattern
pairdist.default

Pairwise distances
project2segment

Move Point To Nearest Line
plot.quad

plot a Spatial Quadrature Scheme
nearest.raster.point

Find Pixel Nearest to a Given Point
predict.kppm

Prediction from a Fitted Cluster Point Process Model
spruces

Spruces Point Pattern
gridweights

Compute Quadrature Weights Based on Grid Counts
subsetget.im

Reset Values in Subset of Image
plot.psp

plot a Spatial Line Segment Pattern
dirichlet

Dirichlet Tessellation of Point Pattern
dirichlet.weights

Compute Quadrature Weights Based on Dirichlet Tessellation
rshift.splitppp

Randomly Shift a List of Point Patterns
pcf.fasp

Pair Correlation Function obtained from array of K functions
nztrees

New Zealand Trees Point Pattern
diagnose.ppm

Diagnostic Plots for Fitted Point Process Model
summary.quad

Summarizing a Quadrature Scheme
eval.fasp

Evaluate Expression Involving Function Arrays
crossdist.default

Pairwise distances between two different sets of points
rshift.psp

Randomly Shift a Line Segment Pattern
Jest

Estimate the J-function
is.owin

Test Whether An Object Is A Window
matclust.estK

Fit the Matern Cluster Point Process by Minimum Contrast
qqplot.ppm

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

Berman-Huntington points and lines data
intersect.tess

Intersection of Two Tessellations
crossdist

Pairwise distances
eval.im

Evaluate Expression Involving Pixel Images
inforder.family

Infinite Order Interaction Family
rjitter

Random Perturbation of a Point Pattern
cut.ppp

Classify Points in a Point Pattern
incircle

Find Largest Circle Inside Window
is.ppp

Test Whether An Object Is A Point Pattern
Pairwise

Generic Pairwise Interaction model
suffstat

Sufficient Statistic of Point Process Model
ewcdf

Weighted Empirical Cumulative Distribution Function
gpc2owin

Convert Polygonal Region into Different Format
ppp.object

Class of Point Patterns
pppmatching.object

Class of Point Matchings
humberside

Humberside Data on Childhood Leukaemia and Lymphoma
hamster

Aherne's hamster tumour data
nncross

Nearest Neighbour in Another Point Pattern
discretise

Safely Convert Point Pattern Window to Binary Mask
density.ppp

Kernel Smoothed Intensity of Point Pattern
shift.psp

Apply Vector Translation To Line Segment Pattern
quadrat.test

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

Fit Point Process Model to Data
summary.owin

Summary of a Spatial Window
rpoint

Generate N Random Points
effectfun

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

Artificial Data Point Pattern
tess

Create a Tessellation
rcell

Simulate Baddeley-Silverman Cell Process
fitted.ppm

Fitted Conditional Intensity for Point Process Model
miplot

Morishita Index Plot
hyperframe

Hyper Data Frame
simdat

Simulated Point Pattern
lgcp.estK

Fit a Log-Gaussian Cox Point Process by Minimum Contrast
plot.im

Plot a Pixel Image
harmonic

Basis for Harmonic Functions
plot.fasp

Plot a Function Array
quantile.im

Sample Quantiles of Pixel Image
pixellate

Convert Point Pattern to Pixel Image
pppdist

Distance Between Two Point Patterns
letterR

Window in Shape of Letter R
localK

Neighbourhood density function
lut

Lookup Tables
rescale

Convert dataset to another unit of length
nncorr

Nearest-Neighbour Correlation of Marked Point Pattern
markstat

Summarise Marks in Every Neighbourhood in a Point Pattern
convexhull.xy

Convex Hull of Points
rmpoispp

Generate Multitype Poisson Point Pattern
rmhmodel.default

Build Point Process Model for Metropolis-Hastings Simulation.
inside.owin

Test Whether Points Are Inside A Window
ord.family

Ord Interaction Process Family
dummy.ppm

Extract Dummy Points Used to Fit a Point Process Model
quadscheme

Generate a Quadrature Scheme from a Point Pattern
summary.ppm

Summarizing a Fitted Point Process Model
rpoispp

Generate Poisson Point Pattern
kstest.ppm

Kolmogorov-Smirnov Test for Point Process Model
contour.im

Contour plot of pixel image
plot.kppm

Plot a fitted cluster point process
quadratcount

Quadrat counting for a point pattern
crossing.psp

Crossing Points of Two Line Segment Patterns
hist.im

Histogram of Pixel Values in an Image
unitname

Name for Unit of Length
plot.splitppp

Plot a List of Point Patterns
rSSI

Simulate Simple Sequential Inhibition
kppm

Fit cluster point process model
summary.listof

Summary of a List of Things
progressreport

Print Progress Reports
rshift

Random Shift
rescale.im

Convert Pixel Image to Another Unit of Length
rmh.ppm

Simulate from a Fitted Point Process Model
solutionset

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

Generate Poisson Random Line Process
dilate.owin

Dilate a Window
subset.psp

Extract Subset of Line Segment Pattern
pairdist

Pairwise distances
reduced.sample

Reduced Sample Estimator using Histogram Data
subset.fv

Extract Subset of Function Values
crossdist.ppp

Pairwise distances between two different point patterns
plot.listof

Plot a List of Things
marktable

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

Compute Integral of Function Against Cumulative Distribution
density.psp

Kernel Smoothing of Line Segment Pattern
vertices

Vertices of a Window
rmhmodel.ppm

Interpret Fitted Model for Metropolis-Hastings Simulation.
is.multitype.ppm

Test Whether A Point Process Model is Multitype
thomas.estK

Fit the Thomas Point Process by Minimum Contrast
subset.ppp

Extract or Replace Subset of Point Pattern
summary.ppp

Summary of a Point Pattern Dataset
rmhstart

Determine Initial State for Metropolis-Hastings Simulation.
subset.splitppp

Extract or Replace Sub-Patterns
rsyst

Simulate systematic random point pattern
subset.fasp

Extract Subset of Function Array
print.ppp

Print Brief Details of a Point Pattern Dataset
im

Create a Pixel Image Object
affine.ppp

Apply Affine Transformation To Point Pattern
model.images

Compute Images of Constructed Covariates
print.psp

Print Brief Details of a Line Segment Pattern Dataset
rstrat

Simulate Stratified Random Point Pattern
shift.ppp

Apply Vector Translation To Point Pattern
update.kppm

Update a Fitted Cluster Point Process Model
tiles

Extract List of Tiles in a Tessellation
complement.owin

Take Complement of a Window
ponderosa

Ponderosa Pine Tree Point Pattern
smooth.ppp

Spatial smoothing of observations at irregular points
shift

Apply Vector Translation
finpines

Pine saplings in Finland.
plot.ppp

plot a Spatial Point Pattern
update.ppm

Update a Fitted Point Process Model
shift.owin

Apply Vector Translation To Window
kaplan.meier

Kaplan-Meier Estimator using Histogram Data
pcf.fv

Pair Correlation Function obtained from K Function
pairsat.family

Saturated Pairwise Interaction Point Process Family
pairwise.family

Pairwise Interaction Process Family
distmap

Distance Map
swedishpines

Swedish Pines Point Pattern
spatstat-internal

Internal spatstat functions
multiplicity.ppp

Count Multiplicity of Duplicate Points
redwoodfull

California Redwoods Point Pattern (Entire Dataset)
psp

Create a Line Segment Pattern
is.multitype.ppp

Test Whether A Point Pattern is Multitype
nndist

Nearest neighbour distances
fitin.ppm

Extract the Interaction from a Fitted Point Process Model
opening.owin

Morphological Opening of a Window
superimposePSP

Superimpose Several Line Segment Patterns
Kcross.inhom

Inhomogeneous Cross K Function
envelope

Simulation envelopes of summary function
Strauss

The Strauss Point Process Model
split.im

Divide Image Into Sub-images
duplicated.ppp

Determine Duplicated Points in a Spatial Point Pattern
setcov

Set Covariance of a Window
compatible.fv

Test Whether Two Function Objects Are Compatible
nbfires

Point Patterns of New Brunswick Forest Fires
subset.im

Extract Subset of Image
compatible.im

Test Whether Two Pixel Images Are Compatible
data.ppm

Extract Original Data from a Fitted Point Process Model
japanesepines

Japanese Pines Point Pattern
model.matrix.ppm

Extract Design Matrix from Point Process Model
midpoints.psp

Midpoints of Line Segment Pattern
rmpoint

Generate N Random Multitype Points
Iest

Estimate the I-function
simulate.kppm

Simulate a fitted cluster point process model.
density.splitppp

Kernel Smoothed Intensity of Split Point Pattern
as.im

Convert to Pixel Image
bdist.pixels

Distance to Boundary of Window
quad.object

Class of Quadrature Schemes
is.subset.owin

Determine Whether One Window is Contained In Another
print.im

Print Brief Details of an Image
rMaternI

Simulate Matern Model I
[.quad

Subset of Quadrature Scheme
reach

Interaction Distance of a Point Process
amacrine

Hughes' Amacrine Cell Data
bounding.box

Bounding Box of a Window or Point Pattern
endpoints.psp

Endpoints of Line Segment Pattern
Softcore

The Soft Core Point Process Model
plot.plotppm

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

Print a Quadrature Scheme
ppm.object

Class of Fitted Point Process Models
quadrat.test.splitppp

Chi-Squared Test of CSR for Split Point Pattern
clarkevans

Clark and Evans Aggregation Index
area.owin

Area of a Window
rthin

Random Thinning
ripras

Estimate window from points alone
split.ppp

Divide Point Pattern into Sub-patterns
pcf.ppp

Pair Correlation Function of Point Pattern
is.multitype

Test whether Object is Multitype
MultiStrauss

The Multitype Strauss Point Process Model
pairdist.ppp

Pairwise distances
summary.splitppp

Summary of a Split Point Pattern
pcf

Pair Correlation Function
scanpp

Read Point Pattern From Data File
clickpoly

Interactively Define a Polygon
eem

Exponential Energy Marks
Kest

K-function
append.psp

Combine Two Line Segment Patterns
matchingdist

Distance for a Point Pattern Matching
Gmulti

Marked Nearest Neighbour Distance Function
affine

Apply Affine Transformation
trim.rectangle

Cut margins from rectangle
erode.owin

Erode a Window
nndist.psp

Nearest neighbour distances between line segments
lurking

Lurking variable plot
pppmatching

Create a Point Matching
rshift.ppp

Randomly Shift a Point Pattern
anemones

Beadlet Anemones Data
Kcross

Multitype K Function (Cross-type)
Lcross

Multitype L-function (cross-type)
predict.ppm

Prediction from a Fitted Point Process Model
as.mask

Pixel Image Approximation of a Window
ants

Harkness-Isham ants' nests data
profilepl

Profile Maximum Pseudolikelihood
is.marked

Test Whether Marks Are Present
raster.x

Cartesian Coordinates for a Pixel Raster
rNeymanScott

Simulate Neyman-Scott Process
Kmeasure

Reduced Second Moment Measure
distmap.ppp

Distance Map of Point Pattern
quad.ppm

Extract Quadrature Scheme Used to Fit a Point Process Model
nearestsegment

Find Line Segment Nearest to Each Point
vcov.ppm

Variance-Covariance Matrix for a Fitted Point Process Model
runifpoint

Generate N Uniform Random Points
owin.object

Class owin
adaptive.density

Intensity Estimate of Point Pattern Using Tessellation
Poisson

Poisson Point Process Model
gridcentres

Rectangular grid of points
spatstat

The Spatstat Package
eval.fv

Evaluate Expression Involving Functions
Kdot

Multitype K Function (i-to-any)
psp.object

Class of Line Segment Patterns
LennardJones

The Lennard-Jones Potential
rmh.default

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

Place Points Evenly Along Specified Lines
is.ppm

Test Whether An Object Is A Fitted Point Process Model
rlinegrid

Generate grid of parallel lines with random displacement
bounding.box.xy

Convex Hull of Points
by.ppp

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

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

Difference of Disc Areas
as.tess

Convert Data To Tessellation
cells

Biological Cells Point Pattern
distmap.psp

Distance Map of Line Segment Pattern
betacells

Beta Ganglion Cells in Cat Retina
as.data.frame.ppp

Coerce Point Pattern to a Data Frame
rescale.psp

Convert Line Segment Pattern to Another Unit of Length
crossdist.psp

Pairwise distances between two different line segment patterns
runifdisc

Generate N Uniform Random Points in a Disc
Gest

Nearest Neighbour Distance Function G
pairdist.psp

Pairwise distances between line segments
selfcrossing.psp

Crossing Points in a Line Segment Pattern
rescue.rectangle

Convert Window Back To Rectangle
summary.im

Summarizing a Pixel Image
closing.owin

Morphological Closing of a Window
is.marked.ppp

Test Whether A Point Pattern is Marked
SatPiece

Piecewise Constant Saturated Pairwise Interaction Point Process Model
residuals.ppm

Residuals for Fitted Point Process Model
rpoisppOnLines

Generate Poisson Point Pattern on Line Segments
eval.hyper

Evaluate an Expression in Each Row of a Hyperframe
as.ppp

Convert Data To Class ppp
colourmap

Colour Lookup Tables
urkiola

Urkiola Woods Point Pattern
print.ppm

Print a Fitted Point Process Model
as.data.frame.psp

Coerce Line Segment Pattern to a Data Frame
levelset

Level Set of a Pixel Image
plot.tess

Plot a tessellation
mean.im

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

Simulate Matern Cluster Process
km.rs

Kaplan-Meier and Reduced Sample Estimator using Histograms
allstats

Calculate four standard summary functions of a point pattern.
ganglia

Beta Ganglion Cells in Cat Retina, Old Version
delaunay

Delaunay Triangulation of Point Pattern
nnwhich

Nearest neighbour
with.fv

Evaluate an Expression in a Function Table
Ldot

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

Interactively Add Points
rlabel

Random Re-Labelling of Point Pattern
rmhmodel.list

Define Point Process Model for Metropolis-Hastings Simulation.
plot.fv

Plot Function Valuesn
chorley

Chorley-Ribble Cancer Data
Jmulti

Marked J Function
MultiStraussHard

The Multitype/Hard Core Strauss Point Process Model
StraussHard

The Strauss / Hard Core Point Process Model
affine.owin

Apply Affine Transformation To Window
Kdot.inhom

Inhomogeneous Multitype K Dot Function
Kmulti

Marked K-Function
affine.psp

Apply Affine Transformation To Line Segment Pattern
AreaInter

The Area Interaction Point Process Model
as.owin

Convert Data To Class owin
as.rectangle

Window Frame
rotate.owin

Rotate a Window
Geyer

Geyer's Saturation Point Process Model
applynbd

Apply Function to Every Neighbourhood in a Point Pattern
anova.ppm

ANOVA for Fitted Point Process Models
subset.listof

Extract or Replace Subset of a List of Things
OrdThresh

Ord's Interaction model
Linhom

L-function
Saturated

Saturated Pairwise Interaction model
alltypes

Calculate Summary Statistic for All Types in a Multitype Point Pattern
Kest.fft

K-function using FFT
coef.ppm

Coefficients of Fitted Point Process Model
Jcross

Multitype J Function (i-to-j)
setmarks

Set or Reset the Marks in a Point Pattern
DiggleGratton

Diggle-Gratton model
runifpointOnLines

Generate N Uniform Random Points On Line Segments
unmark

Remove Marks
as.matrix.im

Convert Pixel Image to Matrix
interp.im

Interpolate a Pixel Image
Jdot

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

Distance Map of Window
shift.im

Apply Vector Translation To Pixel Image
angles.psp

Orientation Angles of Line Segments
is.im

Test Whether An Object Is A Pixel Image
eroded.areas

Areas of Morphological Erosions
compatible.fasp

Test Whether Two Function Arrays Are Compatible
fryplot

Fry Plot of Point Pattern
persp.im

Perspective Plot of Pixel Image
BadGey

Hybrid Geyer Point Process Model
bramblecanes

Hutchings' Bramble Canes data
bei

Tropical rain forest trees
bdist.points

Distance to Boundary of Window
Fest

Estimate the empty space function F
blur

Apply Gaussian Blur to a Pixel Image
Kinhom

Inhomogeneous K-function
rescale.owin

Convert Window to Another Unit of Length
im.object

Class of Images
rmhcontrol

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

Convert Data To Class psp
quadrats

Divide Region into Quadrats
by.im

Apply Function to Image Broken Down by Factor
[.tess

Extract or Replace Subset of Tessellation
centroid.owin

Centroid of a window
Gcross

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

The Piecewise Constant Pairwise Interaction Point Process Model
fv.object

Data Frames of Function Values