Learn R Programming

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

spatstat (version 1.14-5)

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

License

GPL (>= 2)

Maintainer

Adrian Baddeley

Last Published

March 22nd, 2025

Functions in spatstat (1.14-5)

fitted.ppm

Fitted Conditional Intensity for Point Process Model
diameter

Diameter of a Window
logLik.ppm

Log Likelihood for Poisson Point Process Model
pcfcross

Multitype pair correlation function
plot.fasp

Plot a Function Array
rmhstart

Determine Initial State for Metropolis-Hastings Simulation.
psp.object

Class of Line Segment Patterns
rlabel

Random Re-Labelling of Point Pattern
rsyst

Simulate systematic random point pattern
summary.listof

Summary of a List of Things
marktable

Tabulate Marks in Neighbourhood of Every Point in a Point Pattern
lengths.psp

Lengths of Line Segments
scanpp

Read Point Pattern From Data File
cut.im

Convert Pixel Image from Numeric to Factor
fasp.object

Function Arrays for Spatial Patterns
distmap.owin

Distance Map of Window
fv.object

Data Frames of Function Values
rMaternI

Simulate Matern Model I
eem

Exponential Energy Marks
spatstat-deprecated

Deprecated spatstat functions
crossdist.ppp

Pairwise distances between two different point patterns
ppm

Fit Point Process Model to Data
ewcdf

Weighted Empirical Cumulative Distribution Function
rMaternII

Simulate Matern Model II
subset.listof

Extract or Replace Subset of a List of Things
gridweights

Compute Quadrature Weights Based on Grid Counts
nbfires

Point Patterns of New Brunswick Forest Fires
plot.ppm

plot a Fitted Point Process Model
endpoints.psp

Endpoints of Line Segment Pattern
dilate.owin

Dilate a Window
kstest.ppm

Kolmogorov-Smirnov Test for Point Process Model
rshift

Random Shift
dirichlet

Dirichlet Tessellation of Point Pattern
is.marked.ppm

Test Whether A Point Process Model is Marked
inside.owin

Test Whether Points Are Inside A Window
subset.ppp

Extract or Replace Subset of Point Pattern
update.ppm

Update a Fitted Point Process Model
pixelquad

Quadrature Scheme Based on Pixel Grid
default.dummy

Generate a Default Pattern of Dummy Points
quadratcount

Quadrat counting for a point pattern
superimpose

Superimpose Several Point Patterns
harmonic

Basis for Harmonic Functions
letterR

Window in Shape of Letter R
owin

Create a Window
coef.ppm

Coefficients of Fitted Point Process Model
japanesepines

Japanese Pines Point Pattern
union.quad

Union of Data and Dummy Points
tess

Create a Tessellation
plot.ppp

plot a Spatial Point Pattern
residualspaper

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

Test Whether An Object Is A Point Pattern
rescale.ppp

Convert Point Pattern to Another Unit of Length
localK

Neighbourhood density function
crossdist.psp

Pairwise distances between two different line segment patterns
murchison

Murchison gold deposits
dummy.ppm

Extract Dummy Points Used to Fit a Point Process Model
ganglia

Beta Ganglion Cells in Cat Retina, Old Version
rescale.psp

Convert Line Segment Pattern to Another Unit of Length
eroded.areas

Areas of Morphological Erosions
finpines

Pine saplings in Finland.
print.im

Print Brief Details of an Image
rescale.im

Convert Pixel Image to Another Unit of Length
crossing.psp

Crossing Points of Two Line Segment Patterns
expand.owin

Expand Window By Factor
corners

Corners of a rectangle
by.im

Apply Function to Image Broken Down by Factor
plot.plotppm

Plot a plotppm Object Created by plot.ppm
lansing

Lansing Woods Point Pattern
intersect.owin

Intersection or Union of Two Windows
diagnose.ppm

Diagnostic Plots for Fitted Point Process Model
demopat

Artificial Data Point Pattern
mean.im

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

Find Largest Circle Inside Window
multiplicity.ppp

Count Multiplicity of Duplicate Points
rmpoint

Generate N Random Multitype Points
Kmulti

Marked K-Function
print.psp

Print Brief Details of a Line Segment Pattern Dataset
with.fv

Evaluate an Expression in a Function Table
pcf.ppp

Pair Correlation Function of Point Pattern
ord.family

Ord Interaction Process Family
matclust.estK

Fit the Matern Cluster Point Process by Minimum Contrast
discretise

Safely Convert Point Pattern Window to Binary Mask
eval.im

Evaluate Expression Involving Pixel Images
rpoispp

Generate Poisson Point Pattern
rotate.psp

Rotate a Line Segment Pattern
is.multitype.ppm

Test Whether A Point Process Model is Multitype
reduced.sample

Reduced Sample Estimator using Histogram Data
BadGey

Hybrid Geyer Point Process Model
is.multitype

Test whether Object is Multitype
plot.psp

plot a Spatial Line Segment Pattern
plot.kppm

Plot a fitted cluster point process
erode.owin

Erode a Window
quadratresample

Resample a Point Pattern by Resampling Quadrats
distmap

Distance Map
pairwise.family

Pairwise Interaction Process Family
rmhcontrol

Set Control Parameters for Metropolis-Hastings Algorithm.
rmh

Simulate point patterns using the Metropolis-Hastings algorithm.
rshift.psp

Randomly Shift a Line Segment Pattern
pairsat.family

Saturated Pairwise Interaction Point Process Family
hist.im

Histogram of Pixel Values in an Image
crossdist

Pairwise distances
plot.listof

Plot a List of Things
nnwhich

Nearest neighbour
eval.hyper

Evaluate an Expression in Each Row of a Hyperframe
model.matrix.ppm

Extract Design Matrix from Point Process Model
subset.im

Extract Subset of Image
is.im

Test Whether An Object Is A Pixel Image
shift.im

Apply Vector Translation To Pixel Image
km.rs

Kaplan-Meier and Reduced Sample Estimator using Histograms
humberside

Humberside Data on Childhood Leukaemia and Lymphoma
setcov

Set Covariance of a Window
persp.im

Perspective Plot of Pixel Image
subset.splitppp

Extract or Replace Sub-Patterns
rmhmodel.list

Define Point Process Model for Metropolis-Hastings Simulation.
rmhmodel

Define Point Process Model for Metropolis-Hastings Simulation.
markcorr

Mark Correlation Function
psp

Create a Line Segment Pattern
rescale.owin

Convert Window to Another Unit of Length
quadscheme

Generate a Quadrature Scheme from a Point Pattern
is.marked.ppp

Test Whether A Point Pattern is Marked
setmarks

Set or Reset the Marks in a Point Pattern
rSSI

Simulate Simple Sequential Inhibition
rMatClust

Simulate Matern Cluster Process
print.owin

Print Brief Details of a Spatial Window
pairdist.default

Pairwise distances
summary.im

Summarizing a Pixel Image
[.tess

Extract or Replace Subset of Tessellation
im.object

Class of Images
progressreport

Print Progress Reports
rNeymanScott

Simulate Neyman-Scott Process
quadrats

Divide Region into Quadrats
is.subset.owin

Determine Whether One Window is Contained In Another
distmap.psp

Distance Map of Line Segment Pattern
rshift.ppp

Randomly Shift a Point Pattern
vertices

Vertices of a Window
predict.ppm

Prediction from a Fitted Point Process Model
rmh.ppm

Simulate from a Fitted Point Process Model
summary.owin

Summary of a Spatial Window
rotate.owin

Rotate a Window
ppp

Create a Point Pattern
rotate.ppp

Rotate a Point Pattern
quad.object

Class of Quadrature Schemes
summary.psp

Summary of a Line Segment Pattern Dataset
midpoints.psp

Midpoints of Line Segment Pattern
rmh.default

Simulate Point Process Models using the Metropolis-Hastings Algorithm.
ppm.object

Class of Fitted Point Process Models
redwoodfull

California Redwoods Point Pattern (Entire Dataset)
quadrat.test

Chi-Squared Dispersion Test for Spatial Point Pattern Based on Quadrat Counts
rescue.rectangle

Convert Window Back To Rectangle
rthin

Random Thinning
spruces

Spruces Point Pattern
rcell

Simulate Baddeley-Silverman Cell Process
shift.psp

Apply Vector Translation To Line Segment Pattern
copper

Berman-Huntington points and lines data
plot.quad

plot a Spatial Quadrature Scheme
rescale

Convert dataset to another unit of length
tiles

Extract List of Tiles in a Tessellation
gridcentres

Rectangular grid of points
quantile.im

Sample Quantiles of Pixel Image
print.ppm

Print a Fitted Point Process Model
rpoisline

Generate Poisson Random Line Process
profilepl

Profile Maximum Pseudolikelihood
cut.ppp

Classify Points in a Point Pattern
kaplan.meier

Kaplan-Meier Estimator using Histogram Data
nncross

Nearest Neighbour in Another Point Pattern
data.ppm

Extract Original Data from a Fitted Point Process Model
delaunay

Delaunay Triangulation of Point Pattern
fitin.ppm

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

Plot a Spatial Window
redwood

California Redwoods Point Pattern (Ripley's Subset)
ripras

Estimate window from points alone
spatstat.options

Internal Options in Spatstat Package
rmhmodel.default

Build Point Process Model for Metropolis-Hastings Simulation.
OrdThresh

Ord's Interaction model
distmap.ppp

Distance Map of Point Pattern
summary.splitppp

Summary of a Split Point Pattern
rotate

Rotate
hamster

Aherne's hamster tumour data
identify.ppp

Identify Points in a Point Pattern
affine.psp

Apply Affine Transformation To Line Segment Pattern
gpc2owin

Convert Polygonal Region into Different Format
subset.fv

Extract Subset of Function Values
spatstat-internal

Internal spatstat functions
trim.rectangle

Cut margins from rectangle
pcf.fasp

Pair Correlation Function obtained from array of K functions
as.psp

Convert Data To Class psp
nncorr

Nearest-Neighbour Correlation of Marked Point Pattern
dirichlet.weights

Compute Quadrature Weights Based on Dirichlet Tessellation
is.marked

Test Whether Marks Are Present
split.im

Divide Image Into Sub-images
rstrat

Simulate Stratified Random Point Pattern
update.kppm

Update a Fitted Cluster Point Process Model
effectfun

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

Test Whether An Object Is A Fitted Point Process Model
nndist.psp

Nearest neighbour distances between line segments
duplicated.ppp

Determine Duplicated Points in a Spatial Point Pattern
square

Square Window
kppm

Fit cluster point process model
subset.fasp

Extract Subset of Function Array
hyperframe

Hyper Data Frame
Gest

Nearest Neighbour Distance Function G
plot.im

Plot a Pixel Image
model.images

Compute Images of Constructed Covariates
mincontrast

Method of Minimum Contrast
complement.owin

Take Complement of a Window
Ord

Generic Ord Interaction model
predict.kppm

Prediction from a Fitted Cluster Point Process Model
plot.tess

Plot a tessellation
pcf

Pair Correlation Function
as.rectangle

Window Frame
density.psp

Kernel Smoothing of Line Segment Pattern
lurking

Lurking variable plot
Gdot

Multitype Nearest Neighbour Distance Function (i-to-any)
intersect.tess

Intersection of Two Tessellations
eval.fv

Evaluate Expression Involving Functions
rmhmodel.ppm

Interpret Fitted Model for Metropolis-Hastings Simulation.
pcf.fv

Pair Correlation Function obtained from K Function
nndist

Nearest neighbour distances
Strauss

The Strauss Point Process Model
qqplot.ppm

Q-Q Plot of Residuals from Fitted Point Process Model
eval.fasp

Evaluate Expression Involving Function Arrays
is.multitype.ppp

Test Whether A Point Pattern is Multitype
matchingdist

Distance for a Point Pattern Matching
pairdist.ppp

Pairwise distances
pairdist

Pairwise distances
levelset

Level Set of a Pixel Image
append.psp

Combine Two Line Segment Patterns
Kcross.inhom

Inhomogeneous Cross K Function
print.ppp

Print Brief Details of a Point Pattern Dataset
raster.x

Cartesian Coordinates for a Pixel Raster
split.ppp

Divide Point Pattern into Sub-patterns
summary.quad

Summarizing a Quadrature Scheme
disc

Circular Window
shift

Apply Vector Translation
as.tess

Convert Data To Tessellation
rjitter

Random Perturbation of a Point Pattern
pppmatching.object

Class of Point Matchings
pairdist.psp

Pairwise distances between line segments
StraussHard

The Strauss / Hard Core Point Process Model
residuals.ppm

Residuals for Fitted Point Process Model
rGaussPoisson

Simulate Gauss-Poisson Process
smooth.ppp

Spatial smoothing of observations at irregular points
density.splitppp

Kernel Smoothed Intensity of Split Point Pattern
Kmeasure

Reduced Second Moment Measure
rmpoispp

Generate Multitype Poisson Point Pattern
Poisson

Poisson Point Process Model
Kdot

Multitype K Function (i-to-any)
Fest

Estimate the empty space function F
subset.psp

Extract Subset of Line Segment Pattern
plot.hyperframe

Plot Entries in a Hyperframe
swedishpines

Swedish Pines Point Pattern
DiggleGratton

Diggle-Gratton model
owin.object

Class owin
vcov.ppm

Variance-Covariance Matrix for a Fitted Point Process Model
stieltjes

Compute Integral of Function Against Cumulative Distribution
quad.ppm

Extract Quadrature Scheme Used to Fit a Point Process Model
rlinegrid

Generate grid of parallel lines with random displacement
Lest

L-function
rThomas

Simulate Thomas Process
compatible.im

Test Whether Two Pixel Images Are Compatible
Jmulti

Marked J Function
Jcross

Multitype J Function (i-to-j)
urkiola

Urkiola Woods Point Pattern
nearest.raster.point

Find Pixel Nearest to a Given Point
Kdot.inhom

Inhomogeneous Multitype K Dot Function
MultiStrauss

The Multitype Strauss Point Process Model
angles.psp

Orientation Angles of Line Segments
anemones

Beadlet Anemones Data
clarkevans

Clark and Evans Aggregation Index
Lcross

Multitype L-function (cross-type)
Iest

Estimate the I-function
rshift.splitppp

Randomly Shift a List of Point Patterns
Kest

K-function
Gcross

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

Multitype J Function (i-to-any)
bei

Tropical rain forest trees
reach

Interaction Distance of a Point Process
plot.fv

Plot Function Valuesn
as.im

Convert to Pixel Image
simulate.kppm

Simulate a fitted cluster point process model.
summary.ppm

Summarizing a Fitted Point Process Model
adaptive.density

Intensity Estimate of Point Pattern Using Tessellation
allstats

Calculate four standard summary functions of a point pattern.
ponderosa

Ponderosa Pine Tree Point Pattern
compatible.fv

Test Whether Two Function Objects Are Compatible
bounding.box.xy

Convex Hull of Points
Ldot

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

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

Remove Marks from a Marked Point Pattern
ants

Harkness-Isham ants' nests data
compatible.fasp

Test Whether Two Function Arrays Are Compatible
lgcp.estK

Fit a Log-Gaussian Cox Point Process by Minimum Contrast
bdist.pixels

Distance to Boundary of Window
Jest

Estimate the J-function
as.matrix.im

Convert Pixel Image to Matrix
envelope

Simulation envelopes of summary function
bounding.box

Bounding Box of a Window or Point Pattern
blur

Apply Gaussian Blur to a Pixel Image
concatxy

Concatenate x,y Coordinate Vectors
applynbd

Apply Function to Every Neighbourhood in a Point Pattern
as.owin

Convert Data To Class owin
bramblecanes

Hutchings' Bramble Canes data
unitname

Name for Unit of Length
runifpoint

Generate N Uniform Random Points
im

Create a Pixel Image Object
as.data.frame.ppp

Coerce Point Pattern to a Data Frame
shift.ppp

Apply Vector Translation To Point Pattern
interp.im

Interpolate a Pixel Image
clickppp

Interactively Add Points
is.owin

Test Whether An Object Is A Window
runifdisc

Generate N Uniform Random Points in a Disc
pppmatching

Create a Point Matching
density.ppp

Kernel Smoothed Intensity of Point Pattern
inforder.family

Infinite Order Interaction Family
nztrees

New Zealand Trees Point Pattern
crossdist.default

Pairwise distances between two different sets of points
longleaf

Longleaf Pines Point Pattern
simdat

Simulated Point Pattern
rStrauss

Perfect Simulation of the Strauss Process
print.quad

Print a Quadrature Scheme
ppp.object

Class of Point Patterns
Kcross

Multitype K Function (Cross-type)
markstat

Summarise Marks in Every Neighbourhood in a Point Pattern
rpoint

Generate N Random Points
solutionset

Evaluate Logical Expression Involving Pixel Images and Return Region Where Expression is True
selfcrossing.psp

Crossing Points in a Line Segment Pattern
subsetget.im

Reset Values in Subset of Image
PairPiece

The Piecewise Constant Pairwise Interaction Point Process Model
[.quad

Subset of Quadrature Scheme
thomas.estK

Fit the Thomas Point Process by Minimum Contrast
affine

Apply Affine Transformation
bdist.points

Distance to Boundary of Window
Softcore

The Soft Core Point Process Model
spatstat

The Spatstat Package
plot.splitppp

Plot a List of Point Patterns
Kest.fft

K-function using FFT
spokes

Spokes pattern of dummy points
Gmulti

Marked Nearest Neighbour Distance Function
AreaInter

The Area Interaction Point Process Model
affine.owin

Apply Affine Transformation To Window
summary.ppp

Summary of a Point Pattern Dataset
clickpoly

Interactively Define a Polygon
as.mask

Pixel Image Approximation of a Window
Saturated

Saturated Pairwise Interaction model
affine.ppp

Apply Affine Transformation To Point Pattern
areadiff

Difference of Disc Areas
convexhull.xy

Convex Hull of Points
cells

Biological Cells Point Pattern
centroid.owin

Centroid of a window
unique.ppp

Extract Unique Points from a Spatial Point Pattern
betacells

Beta Ganglion Cells in Cat Retina
amacrine

Hughes' Amacrine Cell Data
chorley

Chorley-Ribble Cancer Data
area.owin

Area of a Window
LennardJones

The Lennard-Jones Potential
as.ppp

Convert Data To Class ppp
by.ppp

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

Sufficient Statistic of Point Process Model
pppdist

Distance Between Two Point Patterns
SatPiece

Piecewise Constant Saturated Pairwise Interaction Point Process Model
Pairwise

Generic Pairwise Interaction model
MultiStraussHard

The Multitype/Hard Core Strauss Point Process Model
shift.owin

Apply Vector Translation To Window
Kinhom

Inhomogeneous K-function
Linhom

L-function
Geyer

Geyer's Saturation Point Process Model
anova.ppm

ANOVA for Fitted Point Process Models
contour.im

Contour plot of pixel image