Learn R Programming

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

spatstat (version 1.14-9)

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-9

License

GPL (>= 2)

Maintainer

Adrian Baddeley

Last Published

March 22nd, 2025

Functions in spatstat (1.14-9)

Geyer

Geyer's Saturation Point Process Model
Pairwise

Generic Pairwise Interaction model
as.rectangle

Window Frame
rNeymanScott

Simulate Neyman-Scott Process
rmh.default

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

Print Brief Details of a Spatial Window
runifpoint

Generate N Uniform Random Points
quad.object

Class of Quadrature Schemes
cut.im

Convert Pixel Image from Numeric to Factor
BadGey

Hybrid Geyer Point Process Model
as.owin

Convert Data To Class owin
Jcross

Multitype J Function (i-to-j)
AreaInter

The Area Interaction Point Process Model
Kdot.inhom

Inhomogeneous Multitype K Dot Function
Gmulti

Marked Nearest Neighbour Distance Function
bdist.pixels

Distance to Boundary of Window
Kcross

Multitype K Function (Cross-type)
Lest

L-function
areadiff

Difference of Disc Areas
default.dummy

Generate a Default Pattern of Dummy Points
angles.psp

Orientation Angles of Line Segments
as.mask

Pixel Image Approximation of a Window
append.psp

Combine Two Line Segment Patterns
Kmeasure

Reduced Second Moment Measure
MultiStraussHard

The Multitype/Hard Core Strauss Point Process Model
is.marked

Test Whether Marks Are Present
crossdist

Pairwise distances
hamster

Aherne's hamster tumour data
intersect.tess

Intersection of Two Tessellations
affine.ppp

Apply Affine Transformation To Point Pattern
quadrats

Divide Region into Quadrats
rsyst

Simulate systematic random point pattern
area.owin

Area of a Window
cells

Biological Cells Point Pattern
Iest

Estimate the I-function
distmap

Distance Map
crossdist.ppp

Pairwise distances between two different point patterns
rescue.rectangle

Convert Window Back To Rectangle
Kest.fft

K-function using FFT
is.owin

Test Whether An Object Is A Window
affine.owin

Apply Affine Transformation To Window
alltypes

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

Multitype L-function (cross-type)
applynbd

Apply Function to Every Neighbourhood in a Point Pattern
plot.kppm

Plot a fitted cluster point process
levelset

Level Set of a Pixel Image
eroded.areas

Areas of Morphological Erosions
miplot

Morishita Index Plot
simdat

Simulated Point Pattern
as.ppp

Convert Data To Class ppp
amacrine

Hughes' Amacrine Cell Data
compatible.fv

Test Whether Two Function Objects Are Compatible
dirichlet

Dirichlet Tessellation of Point Pattern
longleaf

Longleaf Pines Point Pattern
compatible.im

Test Whether Two Pixel Images Are Compatible
is.subset.owin

Determine Whether One Window is Contained In Another
Kmulti

Marked K-Function
density.splitppp

Kernel Smoothed Intensity of Split Point Pattern
Kest

K-function
ants

Harkness-Isham ants' nests data
Saturated

Saturated Pairwise Interaction model
as.im

Convert to Pixel Image
Gcross

Multitype Nearest Neighbour Distance Function (i-to-j)
dummy.ppm

Extract Dummy Points Used to Fit a Point Process Model
Jdot

Multitype J Function (i-to-any)
bounding.box.xy

Convex Hull of Points
nearestsegment

Find Line Segment Nearest to Each Point
rmhcontrol

Set Control Parameters for Metropolis-Hastings Algorithm.
fasp.object

Function Arrays for Spatial Patterns
pppmatching.object

Class of Point Matchings
clickppp

Interactively Add Points
spatstat-deprecated

Deprecated spatstat functions
ppm

Fit Point Process Model to Data
murchison

Murchison gold deposits
plot.fasp

Plot a Function Array
harmonic

Basis for Harmonic Functions
is.im

Test Whether An Object Is A Pixel Image
corners

Corners of a rectangle
crossdist.psp

Pairwise distances between two different line segment patterns
LennardJones

The Lennard-Jones Potential
PairPiece

The Piecewise Constant Pairwise Interaction Point Process Model
nncross

Nearest Neighbour in Another Point Pattern
rescale.im

Convert Pixel Image to Another Unit of Length
clarkevans

Clark and Evans Aggregation Index
im

Create a Pixel Image Object
StraussHard

The Strauss / Hard Core Point Process Model
contour.im

Contour plot of pixel image
by.im

Apply Function to Image Broken Down by Factor
identify.ppp

Identify Points in a Point Pattern
ewcdf

Weighted Empirical Cumulative Distribution Function
density.ppp

Kernel Smoothed Intensity of Point Pattern
eem

Exponential Energy Marks
concatxy

Concatenate x,y Coordinate Vectors
shift.im

Apply Vector Translation To Pixel Image
as.matrix.im

Convert Pixel Image to Matrix
quantile.im

Sample Quantiles of Pixel Image
complement.owin

Take Complement of a Window
Linhom

L-function
pairdist.ppp

Pairwise distances
blur

Apply Gaussian Blur to a Pixel Image
intersect.owin

Intersection or Union of Two Windows
print.im

Print Brief Details of an Image
envelope

Simulation envelopes of summary function
setmarks

Set or Reset the Marks in a Point Pattern
eval.fv

Evaluate Expression Involving Functions
diameter

Diameter of a Window
fryplot

Fry Plot of Point Pattern
spatstat-internal

Internal spatstat functions
qqplot.ppm

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

Random Perturbation of a Point Pattern
Fest

Estimate the empty space function F
coef.ppm

Coefficients of Fitted Point Process Model
profilepl

Profile Maximum Pseudolikelihood
rmh.ppm

Simulate from a Fitted Point Process Model
Poisson

Poisson Point Process Model
matchingdist

Distance for a Point Pattern Matching
distmap.ppp

Distance Map of Point Pattern
eval.im

Evaluate Expression Involving Pixel Images
Kcross.inhom

Inhomogeneous Cross K Function
residuals.ppm

Residuals for Fitted Point Process Model
km.rs

Kaplan-Meier and Reduced Sample Estimator using Histograms
is.marked.ppm

Test Whether A Point Process Model is Marked
is.ppp

Test Whether An Object Is A Point Pattern
rMaternI

Simulate Matern Model I
erode.owin

Erode a Window
multiplicity.ppp

Count Multiplicity of Duplicate Points
pixellate

Convert Point Pattern to Pixel Image
Strauss

The Strauss Point Process Model
rmhmodel.ppm

Interpret Fitted Model for Metropolis-Hastings Simulation.
pairsat.family

Saturated Pairwise Interaction Point Process Family
quadratresample

Resample a Point Pattern by Resampling Quadrats
centroid.owin

Centroid of a window
rotate

Rotate
distmap.psp

Distance Map of Line Segment Pattern
data.ppm

Extract Original Data from a Fitted Point Process Model
rpoisline

Generate Poisson Random Line Process
fv.object

Data Frames of Function Values
rpoispp

Generate Poisson Point Pattern
trim.rectangle

Cut margins from rectangle
kaplan.meier

Kaplan-Meier Estimator using Histogram Data
print.quad

Print a Quadrature Scheme
plot.fv

Plot Function Valuesn
subset.fasp

Extract Subset of Function Array
print.psp

Print Brief Details of a Line Segment Pattern Dataset
rescale.owin

Convert Window to Another Unit of Length
subset.psp

Extract Subset of Line Segment Pattern
inside.owin

Test Whether Points Are Inside A Window
redwoodfull

California Redwoods Point Pattern (Entire Dataset)
distmap.owin

Distance Map of Window
chorley

Chorley-Ribble Cancer Data
owin.object

Class owin
Gest

Nearest Neighbour Distance Function G
tess

Create a Tessellation
kppm

Fit cluster point process model
rStrauss

Perfect Simulation of the Strauss Process
plot.ppp

plot a Spatial Point Pattern
rotate.owin

Rotate a Window
pairdist.default

Pairwise distances
OrdThresh

Ord's Interaction model
gridcentres

Rectangular grid of points
endpoints.psp

Endpoints of Line Segment Pattern
quadratcount

Quadrat counting for a point pattern
predict.ppm

Prediction from a Fitted Point Process Model
spruces

Spruces Point Pattern
rlabel

Random Re-Labelling of Point Pattern
model.matrix.ppm

Extract Design Matrix from Point Process Model
as.data.frame.psp

Coerce Line Segment Pattern to a Data Frame
vcov.ppm

Variance-Covariance Matrix for a Fitted Point Process Model
persp.im

Perspective Plot of Pixel Image
pppdist

Distance Between Two Point Patterns
unmark

Remove Marks
copper

Berman-Huntington points and lines data
summary.im

Summarizing a Pixel Image
allstats

Calculate four standard summary functions of a point pattern.
psp.object

Class of Line Segment Patterns
pairwise.family

Pairwise Interaction Process Family
clickpoly

Interactively Define a Polygon
rpoint

Generate N Random Points
discretise

Safely Convert Point Pattern Window to Binary Mask
nncorr

Nearest-Neighbour Correlation of Marked Point Pattern
bramblecanes

Hutchings' Bramble Canes data
spatstat.options

Internal Options in Spatstat Package
compatible.fasp

Test Whether Two Function Arrays Are Compatible
Ord

Generic Ord Interaction model
with.fv

Evaluate an Expression in a Function Table
bei

Tropical rain forest trees
DiggleGratton

Diggle-Gratton model
rmhmodel.default

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

Expand Window By Factor
as.tess

Convert Data To Tessellation
rescale

Convert dataset to another unit of length
cut.ppp

Classify Points in a Point Pattern
summary.splitppp

Summary of a Split Point Pattern
ppm.object

Class of Fitted Point Process Models
bounding.box

Bounding Box of a Window or Point Pattern
localK

Neighbourhood density function
rstrat

Simulate Stratified Random Point Pattern
rmhstart

Determine Initial State for Metropolis-Hastings Simulation.
pcf.fasp

Pair Correlation Function obtained from array of K functions
raster.x

Cartesian Coordinates for a Pixel Raster
anemones

Beadlet Anemones Data
mincontrast

Method of Minimum Contrast
crossdist.default

Pairwise distances between two different sets of points
as.data.frame.ppp

Coerce Point Pattern to a Data Frame
subset.fv

Extract Subset of Function Values
im.object

Class of Images
markstat

Summarise Marks in Every Neighbourhood in a Point Pattern
thomas.estK

Fit the Thomas Point Process by Minimum Contrast
rmh

Simulate point patterns using the Metropolis-Hastings algorithm.
affine

Apply Affine Transformation
rotate.ppp

Rotate a Point Pattern
nnwhich

Nearest neighbour
pairdist.psp

Pairwise distances between line segments
MultiStrauss

The Multitype Strauss Point Process Model
spatstat

The Spatstat Package
residualspaper

Data and Code From JRSS Discussion Paper on Residuals
effectfun

Compute Fitted Effect of a Spatial Covariate in a Point Process Model
quad.ppm

Extract Quadrature Scheme Used to Fit a Point Process Model
rshift.splitppp

Randomly Shift a List of Point Patterns
as.psp

Convert Data To Class psp
nztrees

New Zealand Trees Point Pattern
betacells

Beta Ganglion Cells in Cat Retina
mean.im

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

Estimate the J-function
adaptive.density

Intensity Estimate of Point Pattern Using Tessellation
by.ppp

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

Generate a Quadrature Scheme from a Point Pattern
hyperframe

Hyper Data Frame
shift.owin

Apply Vector Translation To Window
Softcore

The Soft Core Point Process Model
interp.im

Interpolate a Pixel Image
split.ppp

Divide Point Pattern into Sub-patterns
plot.quad

plot a Spatial Quadrature Scheme
dilate.owin

Dilate a Window
crossing.psp

Crossing Points of Two Line Segment Patterns
opening.owin

Morphological Opening of a Window
lengths.psp

Lengths of Line Segments
pcf.fv

Pair Correlation Function obtained from K Function
gpc2owin

Convert Polygonal Region into Different Format
stieltjes

Compute Integral of Function Against Cumulative Distribution
progressreport

Print Progress Reports
rshift.psp

Randomly Shift a Line Segment Pattern
dirichlet.weights

Compute Quadrature Weights Based on Dirichlet Tessellation
plot.splitppp

Plot a List of Point Patterns
rshift.ppp

Randomly Shift a Point Pattern
psp

Create a Line Segment Pattern
affine.psp

Apply Affine Transformation To Line Segment Pattern
model.images

Compute Images of Constructed Covariates
is.ppm

Test Whether An Object Is A Fitted Point Process Model
disc

Circular Window
pppmatching

Create a Point Matching
unitname

Name for Unit of Length
letterR

Window in Shape of Letter R
japanesepines

Japanese Pines Point Pattern
runifdisc

Generate N Uniform Random Points in a Disc
SatPiece

Piecewise Constant Saturated Pairwise Interaction Point Process Model
unique.ppp

Extract Unique Points from a Spatial Point Pattern
Kinhom

Inhomogeneous K-function
superimpose

Superimpose Several Point Patterns
summary.listof

Summary of a List of Things
fitin.ppm

Extract the Interaction from a Fitted Point Process Model
pairdist

Pairwise distances
swedishpines

Swedish Pines Point Pattern
spokes

Spokes pattern of dummy points
Kdot

Multitype K Function (i-to-any)
demopat

Artificial Data Point Pattern
lgcp.estK

Fit a Log-Gaussian Cox Point Process by Minimum Contrast
diagnose.ppm

Diagnostic Plots for Fitted Point Process Model
inforder.family

Infinite Order Interaction Family
print.ppm

Print a Fitted Point Process Model
solutionset

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

Humberside Data on Childhood Leukaemia and Lymphoma
is.multitype

Test whether Object is Multitype
pcf.ppp

Pair Correlation Function of Point Pattern
predict.kppm

Prediction from a Fitted Cluster Point Process Model
nndist.psp

Nearest neighbour distances between line segments
rshift

Random Shift
midpoints.psp

Midpoints of Line Segment Pattern
superimposePSP

Superimpose Several Line Segment Patterns
matclust.estK

Fit the Matern Cluster Point Process by Minimum Contrast
plot.listof

Plot a List of Things
convexhull.xy

Convex Hull of Points
anova.ppm

ANOVA for Fitted Point Process Models
vertices

Vertices of a Window
lansing

Lansing Woods Point Pattern
split.im

Divide Image Into Sub-images
plot.hyperframe

Plot Entries in a Hyperframe
urkiola

Urkiola Woods Point Pattern
subset.im

Extract Subset of Image
rMatClust

Simulate Matern Cluster Process
rSSI

Simulate Simple Sequential Inhibition
plot.tess

Plot a tessellation
lurking

Lurking variable plot
bdist.points

Distance to Boundary of Window
eval.fasp

Evaluate Expression Involving Function Arrays
logLik.ppm

Log Likelihood for Poisson Point Process Model
[.tess

Extract or Replace Subset of Tessellation
rmpoispp

Generate Multitype Poisson Point Pattern
rotate.psp

Rotate a Line Segment Pattern
gridweights

Compute Quadrature Weights Based on Grid Counts
duplicated.ppp

Determine Duplicated Points in a Spatial Point Pattern
fitted.ppm

Fitted Conditional Intensity for Point Process Model
shift.ppp

Apply Vector Translation To Point Pattern
nearest.raster.point

Find Pixel Nearest to a Given Point
nndist

Nearest neighbour distances
hist.im

Histogram of Pixel Values in an Image
incircle

Find Largest Circle Inside Window
Gdot

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

Interaction Distance of a Point Process
ganglia

Beta Ganglion Cells in Cat Retina, Old Version
rThomas

Simulate Thomas Process
markcorr

Mark Correlation Function
ripras

Estimate window from points alone
Jmulti

Marked J Function
subset.ppp

Extract or Replace Subset of Point Pattern
reduced.sample

Reduced Sample Estimator using Histogram Data
shift.psp

Apply Vector Translation To Line Segment Pattern
smooth.ppp

Spatial smoothing of observations at irregular points
rlinegrid

Generate grid of parallel lines with random displacement
square

Square Window
summary.owin

Summary of a Spatial Window
rmhmodel

Define Point Process Model for Metropolis-Hastings Simulation.
simulate.kppm

Simulate a fitted cluster point process model.
is.multitype.ppm

Test Whether A Point Process Model is Multitype
subset.listof

Extract or Replace Subset of a List of Things
rescale.psp

Convert Line Segment Pattern to Another Unit of Length
closing.owin

Morphological Closing of a Window
plot.psp

plot a Spatial Line Segment Pattern
marktable

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

plot a Fitted Point Process Model
selfcrossing.psp

Crossing Points in a Line Segment Pattern
summary.psp

Summary of a Line Segment Pattern Dataset
[.quad

Subset of Quadrature Scheme
rMaternII

Simulate Matern Model II
plot.im

Plot a Pixel Image
delaunay

Delaunay Triangulation of Point Pattern
rcell

Simulate Baddeley-Silverman Cell Process
kstest.ppm

Kolmogorov-Smirnov Test for Point Process Model
pcf

Pair Correlation Function
pixelquad

Quadrature Scheme Based on Pixel Grid
summary.ppm

Summarizing a Fitted Point Process Model
finpines

Pine saplings in Finland.
union.quad

Union of Data and Dummy Points
rmpoint

Generate N Random Multitype Points
nbfires

Point Patterns of New Brunswick Forest Fires
shift

Apply Vector Translation
subset.splitppp

Extract or Replace Sub-Patterns
project2segment

Move Point To Nearest Line
rGaussPoisson

Simulate Gauss-Poisson Process
subsetget.im

Reset Values in Subset of Image
ppp.object

Class of Point Patterns
rmhmodel.list

Define Point Process Model for Metropolis-Hastings Simulation.
is.multitype.ppp

Test Whether A Point Pattern is Multitype
summary.quad

Summarizing a Quadrature Scheme
redwood

California Redwoods Point Pattern (Ripley's Subset)
scanpp

Read Point Pattern From Data File
plot.plotppm

Plot a plotppm Object Created by plot.ppm
density.psp

Kernel Smoothing of Line Segment Pattern
print.ppp

Print Brief Details of a Point Pattern Dataset
update.kppm

Update a Fitted Cluster Point Process Model
owin

Create a Window
summary.ppp

Summary of a Point Pattern Dataset
tiles

Extract List of Tiles in a Tessellation
ponderosa

Ponderosa Pine Tree Point Pattern
setcov

Set Covariance of a Window
rthin

Random Thinning
rescale.ppp

Convert Point Pattern to Another Unit of Length
suffstat

Sufficient Statistic of Point Process Model
Ldot

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

Create a Point Pattern
plot.owin

Plot a Spatial Window
pcfcross

Multitype pair correlation function
quadrat.test

Chi-Squared Dispersion Test for Spatial Point Pattern Based on Quadrat Counts
ord.family

Ord Interaction Process Family
is.marked.ppp

Test Whether A Point Pattern is Marked
eval.hyper

Evaluate an Expression in Each Row of a Hyperframe
update.ppm

Update a Fitted Point Process Model