Learn R Programming

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

spatstat (version 1.14-10)

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

18,534

Version

1.14-10

License

GPL (>= 2)

Maintainer

Adrian Baddeley

Last Published

March 22nd, 2025

Functions in spatstat (1.14-10)

AreaInter

The Area Interaction Point Process Model
Geyer

Geyer's Saturation Point Process Model
Kest.fft

K-function using FFT
by.im

Apply Function to Image Broken Down by Factor
Fest

Estimate the empty space function F
Kinhom

Inhomogeneous K-function
as.im

Convert to Pixel Image
as.matrix.im

Convert Pixel Image to Matrix
Kcross

Multitype K Function (Cross-type)
fv.object

Data Frames of Function Values
convexhull.xy

Convex Hull of Points
affine

Apply Affine Transformation
crossdist.ppp

Pairwise distances between two different point patterns
duplicated.ppp

Determine Duplicated Points in a Spatial Point Pattern
LennardJones

The Lennard-Jones Potential
harmonic

Basis for Harmonic Functions
Pairwise

Generic Pairwise Interaction model
DiggleGratton

Diggle-Gratton model
Jmulti

Marked J Function
matclust.estK

Fit the Matern Cluster Point Process by Minimum Contrast
compatible.fasp

Test Whether Two Function Arrays Are Compatible
blur

Apply Gaussian Blur to a Pixel Image
pixelquad

Quadrature Scheme Based on Pixel Grid
spatstat

The Spatstat Package
compatible.im

Test Whether Two Pixel Images Are Compatible
StraussHard

The Strauss / Hard Core Point Process Model
dirichlet

Dirichlet Tessellation of Point Pattern
append.psp

Combine Two Line Segment Patterns
adaptive.density

Intensity Estimate of Point Pattern Using Tessellation
Gmulti

Marked Nearest Neighbour Distance Function
is.im

Test Whether An Object Is A Pixel Image
nztrees

New Zealand Trees Point Pattern
affine.psp

Apply Affine Transformation To Line Segment Pattern
alltypes

Calculate Summary Statistic for All Types in a Multitype Point Pattern
pairdist.ppp

Pairwise distances
plot.hyperframe

Plot Entries in a Hyperframe
clickpoly

Interactively Define a Polygon
BadGey

Hybrid Geyer Point Process Model
Kest

K-function
finpines

Pine saplings in Finland.
im

Create a Pixel Image Object
kppm

Fit cluster point process model
plot.psp

plot a Spatial Line Segment Pattern
disc

Circular Window
Lest

L-function
ewcdf

Weighted Empirical Cumulative Distribution Function
Gcross

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

Estimate the J-function
levelset

Level Set of a Pixel Image
eval.hyper

Evaluate an Expression in Each Row of a Hyperframe
plot.owin

Plot a Spatial Window
Gest

Nearest Neighbour Distance Function G
gridweights

Compute Quadrature Weights Based on Grid Counts
density.splitppp

Kernel Smoothed Intensity of Split Point Pattern
Linhom

L-function
qqplot.ppm

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

Find Line Segment Nearest to Each Point
rMaternI

Simulate Matern Model I
coef.ppm

Coefficients of Fitted Point Process Model
bdist.points

Distance to Boundary of Window
MultiStraussHard

The Multitype/Hard Core Strauss Point Process Model
model.images

Compute Images of Constructed Covariates
eval.im

Evaluate Expression Involving Pixel Images
Kdot.inhom

Inhomogeneous Multitype K Dot Function
cells

Biological Cells Point Pattern
bounding.box

Bounding Box of a Window or Point Pattern
humberside

Humberside Data on Childhood Leukaemia and Lymphoma
distmap.owin

Distance Map of Window
Strauss

The Strauss Point Process Model
as.tess

Convert Data To Tessellation
Kmeasure

Reduced Second Moment Measure
print.owin

Print Brief Details of a Spatial Window
spatstat-internal

Internal spatstat functions
Kdot

Multitype K Function (i-to-any)
as.mask

Pixel Image Approximation of a Window
quantile.im

Sample Quantiles of Pixel Image
affine.ppp

Apply Affine Transformation To Point Pattern
anova.ppm

ANOVA for Fitted Point Process Models
bramblecanes

Hutchings' Bramble Canes data
fitin.ppm

Extract the Interaction from a Fitted Point Process Model
rescale

Convert dataset to another unit of length
nnwhich

Nearest neighbour
density.ppp

Kernel Smoothed Intensity of Point Pattern
opening.owin

Morphological Opening of a Window
delaunay

Delaunay Triangulation of Point Pattern
hamster

Aherne's hamster tumour data
pairdist.psp

Pairwise distances between line segments
Lcross

Multitype L-function (cross-type)
cut.ppp

Classify Points in a Point Pattern
Ldot

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

Beadlet Anemones Data
thomas.estK

Fit the Thomas Point Process by Minimum Contrast
owin

Create a Window
rotate.psp

Rotate a Line Segment Pattern
rMatClust

Simulate Matern Cluster Process
Ord

Generic Ord Interaction model
ants

Harkness-Isham ants' nests data
identify.ppp

Identify Points in a Point Pattern
density.psp

Kernel Smoothing of Line Segment Pattern
is.owin

Test Whether An Object Is A Window
bounding.box.xy

Convex Hull of Points
complement.owin

Take Complement of a Window
mean.im

Mean, Median and Range of Pixel Values in an Image
affine.owin

Apply Affine Transformation To Window
centroid.owin

Centroid of a window
closing.owin

Morphological Closing of a Window
rlabel

Random Re-Labelling of Point Pattern
by.ppp

Apply a Function to a Point Pattern Broken Down by Factor
contour.im

Contour plot of pixel image
chorley

Chorley-Ribble Cancer Data
letterR

Window in Shape of Letter R
ppp.object

Class of Point Patterns
nndist.psp

Nearest neighbour distances between line segments
pointsOnLines

Place Points Evenly Along Specified Lines
Jcross

Multitype J Function (i-to-j)
rmhmodel.list

Define Point Process Model for Metropolis-Hastings Simulation.
Iest

Estimate the I-function
hist.im

Histogram of Pixel Values in an Image
rthin

Random Thinning
Kcross.inhom

Inhomogeneous Cross K Function
rmh.default

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

Clark and Evans Aggregation Index
runifdisc

Generate N Uniform Random Points in a Disc
gpc2owin

Convert Polygonal Region into Different Format
diagnose.ppm

Diagnostic Plots for Fitted Point Process Model
dirichlet.weights

Compute Quadrature Weights Based on Dirichlet Tessellation
envelope

Simulation envelopes of summary function
areadiff

Difference of Disc Areas
pcf.fv

Pair Correlation Function obtained from K Function
PairPiece

The Piecewise Constant Pairwise Interaction Point Process Model
pcf.ppp

Pair Correlation Function of Point Pattern
compatible.fv

Test Whether Two Function Objects Are Compatible
as.rectangle

Window Frame
Softcore

The Soft Core Point Process Model
endpoints.psp

Endpoints of Line Segment Pattern
ppm.object

Class of Fitted Point Process Models
cut.im

Convert Pixel Image from Numeric to Factor
clickppp

Interactively Add Points
rNeymanScott

Simulate Neyman-Scott Process
diameter

Diameter of a Window
is.ppp

Test Whether An Object Is A Point Pattern
distmap.psp

Distance Map of Line Segment Pattern
effectfun

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

Plot a Pixel Image
summary.im

Summarizing a Pixel Image
rStrauss

Perfect Simulation of the Strauss Process
Saturated

Saturated Pairwise Interaction model
discretise

Safely Convert Point Pattern Window to Binary Mask
concatxy

Concatenate x,y Coordinate Vectors
bei

Tropical rain forest trees
Kmulti

Marked K-Function
corners

Corners of a rectangle
expand.owin

Expand Window By Factor
plot.splitppp

Plot a List of Point Patterns
pppmatching.object

Class of Point Matchings
nearest.raster.point

Find Pixel Nearest to a Given Point
angles.psp

Orientation Angles of Line Segments
copper

Berman-Huntington points and lines data
nbfires

Point Patterns of New Brunswick Forest Fires
simulate.kppm

Simulate a fitted cluster point process model.
quadscheme

Generate a Quadrature Scheme from a Point Pattern
default.dummy

Generate a Default Pattern of Dummy Points
crossing.psp

Crossing Points of Two Line Segment Patterns
square

Square Window
quad.object

Class of Quadrature Schemes
erode.owin

Erode a Window
gridcentres

Rectangular grid of points
eroded.areas

Areas of Morphological Erosions
Jdot

Multitype J Function (i-to-any)
ganglia

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

Dilate a Window
rmpoint

Generate N Random Multitype Points
interp.im

Interpolate a Pixel Image
ponderosa

Ponderosa Pine Tree Point Pattern
fasp.object

Function Arrays for Spatial Patterns
is.ppm

Test Whether An Object Is A Fitted Point Process Model
MultiStrauss

The Multitype Strauss Point Process Model
simdat

Simulated Point Pattern
OrdThresh

Ord's Interaction model
SatPiece

Piecewise Constant Saturated Pairwise Interaction Point Process Model
[.quad

Subset of Quadrature Scheme
Gdot

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

Apply Function to Every Neighbourhood in a Point Pattern
summary.listof

Summary of a List of Things
as.owin

Convert Data To Class owin
inside.owin

Test Whether Points Are Inside A Window
pairdist

Pairwise distances
eval.fasp

Evaluate Expression Involving Function Arrays
redwoodfull

California Redwoods Point Pattern (Entire Dataset)
lengths.psp

Lengths of Line Segments
as.psp

Convert Data To Class psp
data.ppm

Extract Original Data from a Fitted Point Process Model
print.im

Print Brief Details of an Image
as.data.frame.ppp

Coerce Point Pattern to a Data Frame
crossdist.psp

Pairwise distances between two different line segment patterns
dummy.ppm

Extract Dummy Points Used to Fit a Point Process Model
eem

Exponential Energy Marks
incircle

Find Largest Circle Inside Window
fitted.ppm

Fitted Conditional Intensity for Point Process Model
betacells

Beta Ganglion Cells in Cat Retina
lansing

Lansing Woods Point Pattern
is.subset.owin

Determine Whether One Window is Contained In Another
rescale.ppp

Convert Point Pattern to Another Unit of Length
eval.fv

Evaluate Expression Involving Functions
area.owin

Area of a Window
setcov

Set Covariance of a Window
rshift.psp

Randomly Shift a Line Segment Pattern
profilepl

Profile Maximum Pseudolikelihood
ripras

Estimate window from points alone
quadrat.test

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

Simulate Simple Sequential Inhibition
hyperframe

Hyper Data Frame
urkiola

Urkiola Woods Point Pattern
is.multitype.ppm

Test Whether A Point Process Model is Multitype
spokes

Spokes pattern of dummy points
lurking

Lurking variable plot
selfcrossing.psp

Crossing Points in a Line Segment Pattern
is.marked.ppm

Test Whether A Point Process Model is Marked
subset.listof

Extract or Replace Subset of a List of Things
subset.im

Extract Subset of Image
rstrat

Simulate Stratified Random Point Pattern
demopat

Artificial Data Point Pattern
km.rs

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

Test whether Object is Multitype
rsyst

Simulate systematic random point pattern
bdist.pixels

Distance to Boundary of Window
summary.quad

Summarizing a Quadrature Scheme
kaplan.meier

Kaplan-Meier Estimator using Histogram Data
ppp

Create a Point Pattern
union.quad

Union of Data and Dummy Points
as.ppp

Convert Data To Class ppp
inforder.family

Infinite Order Interaction Family
plot.fasp

Plot a Function Array
plot.listof

Plot a List of Things
amacrine

Hughes' Amacrine Cell Data
pppdist

Distance Between Two Point Patterns
stieltjes

Compute Integral of Function Against Cumulative Distribution
midpoints.psp

Midpoints of Line Segment Pattern
pcf.fasp

Pair Correlation Function obtained from array of K functions
update.kppm

Update a Fitted Cluster Point Process Model
crossdist

Pairwise distances
matchingdist

Distance for a Point Pattern Matching
plot.ppp

plot a Spatial Point Pattern
superimposePSP

Superimpose Several Line Segment Patterns
im.object

Class of Images
marktable

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

Quadrat counting for a point pattern
logLik.ppm

Log Likelihood for Poisson Point Process Model
lgcp.estK

Fit a Log-Gaussian Cox Point Process by Minimum Contrast
as.data.frame.psp

Coerce Line Segment Pattern to a Data Frame
rjitter

Random Perturbation of a Point Pattern
markstat

Summarise Marks in Every Neighbourhood in a Point Pattern
predict.kppm

Prediction from a Fitted Cluster Point Process Model
intersect.tess

Intersection of Two Tessellations
markcorr

Mark Correlation Function
distmap

Distance Map
pairwise.family

Pairwise Interaction Process Family
print.ppm

Print a Fitted Point Process Model
rescale.psp

Convert Line Segment Pattern to Another Unit of Length
pixellate

Convert Point Pattern to Pixel Image
superimpose

Superimpose Several Point Patterns
pcfcross

Multitype pair correlation function
fryplot

Fry Plot of Point Pattern
longleaf

Longleaf Pines Point Pattern
localK

Neighbourhood density function
unique.ppp

Extract Unique Points from a Spatial Point Pattern
miplot

Morishita Index Plot
ppm

Fit Point Process Model to Data
plot.ppm

plot a Fitted Point Process Model
plot.quad

plot a Spatial Quadrature Scheme
nncross

Nearest Neighbour in Another Point Pattern
plot.tess

Plot a tessellation
progressreport

Print Progress Reports
nncorr

Nearest-Neighbour Correlation of Marked Point Pattern
predict.ppm

Prediction from a Fitted Point Process Model
summary.psp

Summary of a Line Segment Pattern Dataset
distmap.ppp

Distance Map of Point Pattern
psp

Create a Line Segment Pattern
ord.family

Ord Interaction Process Family
intersect.owin

Intersection or Union of Two Windows
residualspaper

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

Count Multiplicity of Duplicate Points
plot.kppm

Plot a fitted cluster point process
is.marked

Test Whether Marks Are Present
quad.ppm

Extract Quadrature Scheme Used to Fit a Point Process Model
mincontrast

Method of Minimum Contrast
murchison

Murchison gold deposits
plot.plotppm

Plot a plotppm Object Created by plot.ppm
residuals.ppm

Residuals for Fitted Point Process Model
project2segment

Move Point To Nearest Line
rotate.owin

Rotate a Window
print.psp

Print Brief Details of a Line Segment Pattern Dataset
print.ppp

Print Brief Details of a Point Pattern Dataset
rThomas

Simulate Thomas Process
runifpointOnLines

Generate N Uniform Random Points On Line Segments
kstest.ppm

Kolmogorov-Smirnov Test for Point Process Model
model.matrix.ppm

Extract Design Matrix from Point Process Model
pppmatching

Create a Point Matching
psp.object

Class of Line Segment Patterns
rmhstart

Determine Initial State for Metropolis-Hastings Simulation.
rmh.ppm

Simulate from a Fitted Point Process Model
is.marked.ppp

Test Whether A Point Pattern is Marked
quadrats

Divide Region into Quadrats
is.multitype.ppp

Test Whether A Point Pattern is Multitype
rpoisline

Generate Poisson Random Line Process
subsetget.im

Reset Values in Subset of Image
rcell

Simulate Baddeley-Silverman Cell Process
rmhmodel.ppm

Interpret Fitted Model for Metropolis-Hastings Simulation.
reduced.sample

Reduced Sample Estimator using Histogram Data
quadrat.test.splitppp

Chi-Squared Test of CSR for Split Point Pattern
rescale.owin

Convert Window to Another Unit of Length
rlinegrid

Generate grid of parallel lines with random displacement
update.ppm

Update a Fitted Point Process Model
summary.splitppp

Summary of a Split Point Pattern
quadratresample

Resample a Point Pattern by Resampling Quadrats
redwood

California Redwoods Point Pattern (Ripley's Subset)
rGaussPoisson

Simulate Gauss-Poisson Process
rmh

Simulate point patterns using the Metropolis-Hastings algorithm.
rescale.im

Convert Pixel Image to Another Unit of Length
runifpoint

Generate N Uniform Random Points
rshift.splitppp

Randomly Shift a List of Point Patterns
owin.object

Class owin
nndist

Nearest neighbour distances
shift.owin

Apply Vector Translation To Window
japanesepines

Japanese Pines Point Pattern
rmpoispp

Generate Multitype Poisson Point Pattern
rpoispp

Generate Poisson Point Pattern
shift.im

Apply Vector Translation To Pixel Image
shift.psp

Apply Vector Translation To Line Segment Pattern
rmhmodel.default

Build Point Process Model for Metropolis-Hastings Simulation.
rpoisppOnLines

Generate Poisson Point Pattern on Line Segments
persp.im

Perspective Plot of Pixel Image
rshift.ppp

Randomly Shift a Point Pattern
pairsat.family

Saturated Pairwise Interaction Point Process Family
pairdist.default

Pairwise distances
solutionset

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

Swedish Pines Point Pattern
rmhcontrol

Set Control Parameters for Metropolis-Hastings Algorithm.
split.ppp

Divide Point Pattern into Sub-patterns
smooth.ppp

Spatial smoothing of observations at irregular points
split.im

Divide Image Into Sub-images
spatstat.options

Internal Options in Spatstat Package
subset.fasp

Extract Subset of Function Array
rescue.rectangle

Convert Window Back To Rectangle
[.tess

Extract or Replace Subset of Tessellation
subset.psp

Extract Subset of Line Segment Pattern
summary.owin

Summary of a Spatial Window
suffstat

Sufficient Statistic of Point Process Model
spruces

Spruces Point Pattern
unmark

Remove Marks
tess

Create a Tessellation
print.quad

Print a Quadrature Scheme
trim.rectangle

Cut margins from rectangle
raster.x

Cartesian Coordinates for a Pixel Raster
rmhmodel

Define Point Process Model for Metropolis-Hastings Simulation.
unitname

Name for Unit of Length
Poisson

Poisson Point Process Model
allstats

Calculate four standard summary functions of a point pattern.
vertices

Vertices of a Window
subset.fv

Extract Subset of Function Values
reach

Interaction Distance of a Point Process
rotate

Rotate
spatstat-deprecated

Deprecated spatstat functions
crossdist.default

Pairwise distances between two different sets of points
rshift

Random Shift
scanpp

Read Point Pattern From Data File
plot.fv

Plot Function Valuesn
summary.ppm

Summarizing a Fitted Point Process Model
summary.ppp

Summary of a Point Pattern Dataset
rpoint

Generate N Random Points
subset.ppp

Extract or Replace Subset of Point Pattern
with.fv

Evaluate an Expression in a Function Table
tiles

Extract List of Tiles in a Tessellation
shift

Apply Vector Translation
shift.ppp

Apply Vector Translation To Point Pattern
rMaternII

Simulate Matern Model II
rotate.ppp

Rotate a Point Pattern
setmarks

Set or Reset the Marks in a Point Pattern
vcov.ppm

Variance-Covariance Matrix for a Fitted Point Process Model
subset.splitppp

Extract or Replace Sub-Patterns
pcf

Pair Correlation Function