Learn R Programming

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

spatstat (version 1.14-8)

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

License

GPL (>= 2)

Maintainer

Adrian Baddeley

Last Published

March 22nd, 2025

Functions in spatstat (1.14-8)

Jdot

Multitype J Function (i-to-any)
as.ppp

Convert Data To Class ppp
chorley

Chorley-Ribble Cancer Data
as.data.frame.psp

Coerce Line Segment Pattern to a Data Frame
fv.object

Data Frames of Function Values
pairdist.default

Pairwise distances
print.psp

Print Brief Details of a Line Segment Pattern Dataset
summary.quad

Summarizing a Quadrature Scheme
Fest

Estimate the empty space function F
alltypes

Calculate Summary Statistic for All Types in a Multitype Point Pattern
expand.owin

Expand Window By Factor
eval.im

Evaluate Expression Involving Pixel Images
Pairwise

Generic Pairwise Interaction model
Kest.fft

K-function using FFT
incircle

Find Largest Circle Inside Window
adaptive.density

Intensity Estimate of Point Pattern Using Tessellation
OrdThresh

Ord's Interaction model
interp.im

Interpolate a Pixel Image
mincontrast

Method of Minimum Contrast
clickppp

Interactively Add Points
Gdot

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

Pairwise distances
pcfcross

Multitype pair correlation function
dilate.owin

Dilate a Window
applynbd

Apply Function to Every Neighbourhood in a Point Pattern
Kcross

Multitype K Function (Cross-type)
Saturated

Saturated Pairwise Interaction model
SatPiece

Piecewise Constant Saturated Pairwise Interaction Point Process Model
affine.owin

Apply Affine Transformation To Window
density.ppp

Kernel Smoothed Intensity of Point Pattern
as.mask

Pixel Image Approximation of a Window
distmap.ppp

Distance Map of Point Pattern
quad.object

Class of Quadrature Schemes
bramblecanes

Hutchings' Bramble Canes data
complement.owin

Take Complement of a Window
eroded.areas

Areas of Morphological Erosions
anemones

Beadlet Anemones Data
as.tess

Convert Data To Tessellation
amacrine

Hughes' Amacrine Cell Data
eval.hyper

Evaluate an Expression in Each Row of a Hyperframe
compatible.fv

Test Whether Two Function Objects Are Compatible
fryplot

Fry Plot of Point Pattern
rescue.rectangle

Convert Window Back To Rectangle
Jmulti

Marked J Function
fasp.object

Function Arrays for Spatial Patterns
as.rectangle

Window Frame
cut.im

Convert Pixel Image from Numeric to Factor
Kdot

Multitype K Function (i-to-any)
gridcentres

Rectangular grid of points
im.object

Class of Images
finpines

Pine saplings in Finland.
dirichlet

Dirichlet Tessellation of Point Pattern
pcf.fasp

Pair Correlation Function obtained from array of K functions
crossdist.default

Pairwise distances between two different sets of points
envelope

Simulation envelopes of summary function
eval.fv

Evaluate Expression Involving Functions
is.multitype.ppp

Test Whether A Point Pattern is Multitype
disc

Circular Window
kstest.ppm

Kolmogorov-Smirnov Test for Point Process Model
intersect.tess

Intersection of Two Tessellations
crossdist.psp

Pairwise distances between two different line segment patterns
spatstat

The Spatstat Package
lurking

Lurking variable plot
logLik.ppm

Log Likelihood for Poisson Point Process Model
cut.ppp

Classify Points in a Point Pattern
demopat

Artificial Data Point Pattern
coef.ppm

Coefficients of Fitted Point Process Model
MultiStraussHard

The Multitype/Hard Core Strauss Point Process Model
print.ppm

Print a Fitted Point Process Model
plot.plotppm

Plot a plotppm Object Created by plot.ppm
ewcdf

Weighted Empirical Cumulative Distribution Function
dirichlet.weights

Compute Quadrature Weights Based on Dirichlet Tessellation
default.dummy

Generate a Default Pattern of Dummy Points
intersect.owin

Intersection or Union of Two Windows
matchingdist

Distance for a Point Pattern Matching
effectfun

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

Nearest neighbour distances
murchison

Murchison gold deposits
print.owin

Print Brief Details of a Spatial Window
diagnose.ppm

Diagnostic Plots for Fitted Point Process Model
area.owin

Area of a Window
hyperframe

Hyper Data Frame
Jest

Estimate the J-function
rotate.owin

Rotate a Window
as.psp

Convert Data To Class psp
kppm

Fit cluster point process model
plot.fasp

Plot a Function Array
rmhcontrol

Set Control Parameters for Metropolis-Hastings Algorithm.
pcf.fv

Pair Correlation Function obtained from K Function
markcorr

Mark Correlation Function
matclust.estK

Fit the Matern Cluster Point Process by Minimum Contrast
nearestsegment

Find Line Segment Nearest to Each Point
centroid.owin

Centroid of a window
Geyer

Geyer's Saturation Point Process Model
DiggleGratton

Diggle-Gratton model
pairwise.family

Pairwise Interaction Process Family
contour.im

Contour plot of pixel image
Gest

Nearest Neighbour Distance Function G
fitin.ppm

Extract the Interaction from a Fitted Point Process Model
Kmeasure

Reduced Second Moment Measure
nearest.raster.point

Find Pixel Nearest to a Given Point
plot.tess

Plot a tessellation
clickpoly

Interactively Define a Polygon
opening.owin

Morphological Opening of a Window
fitted.ppm

Fitted Conditional Intensity for Point Process Model
diameter

Diameter of a Window
inforder.family

Infinite Order Interaction Family
rmh.ppm

Simulate from a Fitted Point Process Model
quadratcount

Quadrat counting for a point pattern
Kest

K-function
pairsat.family

Saturated Pairwise Interaction Point Process Family
affine

Apply Affine Transformation
Kmulti

Marked K-Function
reach

Interaction Distance of a Point Process
rmhmodel

Define Point Process Model for Metropolis-Hastings Simulation.
multiplicity.ppp

Count Multiplicity of Duplicate Points
gpc2owin

Convert Polygonal Region into Different Format
quadratresample

Resample a Point Pattern by Resampling Quadrats
delaunay

Delaunay Triangulation of Point Pattern
ants

Harkness-Isham ants' nests data
is.ppp

Test Whether An Object Is A Point Pattern
pppmatching

Create a Point Matching
is.marked.ppp

Test Whether A Point Pattern is Marked
summary.im

Summarizing a Pixel Image
letterR

Window in Shape of Letter R
is.ppm

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

Morphological Closing of a Window
pairdist.psp

Pairwise distances between line segments
pppdist

Distance Between Two Point Patterns
clarkevans

Clark and Evans Aggregation Index
distmap

Distance Map
gridweights

Compute Quadrature Weights Based on Grid Counts
shift

Apply Vector Translation
scanpp

Read Point Pattern From Data File
rescale.ppp

Convert Point Pattern to Another Unit of Length
dummy.ppm

Extract Dummy Points Used to Fit a Point Process Model
rMaternI

Simulate Matern Model I
plot.splitppp

Plot a List of Point Patterns
AreaInter

The Area Interaction Point Process Model
mean.im

Mean, Median and Range of Pixel Values in an Image
density.psp

Kernel Smoothing of Line Segment Pattern
rmh.default

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

Simulate Matern Model II
im

Create a Pixel Image Object
pixelquad

Quadrature Scheme Based on Pixel Grid
japanesepines

Japanese Pines Point Pattern
residuals.ppm

Residuals for Fitted Point Process Model
psp

Create a Line Segment Pattern
hamster

Aherne's hamster tumour data
Lest

L-function
midpoints.psp

Midpoints of Line Segment Pattern
km.rs

Kaplan-Meier and Reduced Sample Estimator using Histograms
nndist.psp

Nearest neighbour distances between line segments
model.images

Compute Images of Constructed Covariates
qqplot.ppm

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

Nearest neighbour
Kdot.inhom

Inhomogeneous Multitype K Dot Function
profilepl

Profile Maximum Pseudolikelihood
rjitter

Random Perturbation of a Point Pattern
rshift.psp

Randomly Shift a Line Segment Pattern
levelset

Level Set of a Pixel Image
miplot

Morishita Index Plot
MultiStrauss

The Multitype Strauss Point Process Model
rotate

Rotate
as.data.frame.ppp

Coerce Point Pattern to a Data Frame
lansing

Lansing Woods Point Pattern
Gcross

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

The Piecewise Constant Pairwise Interaction Point Process Model
nncorr

Nearest-Neighbour Correlation of Marked Point Pattern
affine.psp

Apply Affine Transformation To Line Segment Pattern
pcf

Pair Correlation Function
blur

Apply Gaussian Blur to a Pixel Image
plot.quad

plot a Spatial Quadrature Scheme
LennardJones

The Lennard-Jones Potential
setcov

Set Covariance of a Window
convexhull.xy

Convex Hull of Points
plot.hyperframe

Plot Entries in a Hyperframe
ganglia

Beta Ganglion Cells in Cat Retina, Old Version
as.matrix.im

Convert Pixel Image to Matrix
Ord

Generic Ord Interaction model
affine.ppp

Apply Affine Transformation To Point Pattern
rStrauss

Perfect Simulation of the Strauss Process
bdist.points

Distance to Boundary of Window
psp.object

Class of Line Segment Patterns
duplicated.ppp

Determine Duplicated Points in a Spatial Point Pattern
rcell

Simulate Baddeley-Silverman Cell Process
rescale

Convert dataset to another unit of length
data.ppm

Extract Original Data from a Fitted Point Process Model
quadrats

Divide Region into Quadrats
discretise

Safely Convert Point Pattern Window to Binary Mask
rlinegrid

Generate grid of parallel lines with random displacement
rmh

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

Reset Values in Subset of Image
endpoints.psp

Endpoints of Line Segment Pattern
rmpoispp

Generate Multitype Poisson Point Pattern
model.matrix.ppm

Extract Design Matrix from Point Process Model
localK

Neighbourhood density function
lgcp.estK

Fit a Log-Gaussian Cox Point Process by Minimum Contrast
Poisson

Poisson Point Process Model
owin

Create a Window
rstrat

Simulate Stratified Random Point Pattern
bei

Tropical rain forest trees
bounding.box

Bounding Box of a Window or Point Pattern
persp.im

Perspective Plot of Pixel Image
ppm.object

Class of Fitted Point Process Models
plot.fv

Plot Function Valuesn
distmap.owin

Distance Map of Window
by.im

Apply Function to Image Broken Down by Factor
by.ppp

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

Pairwise distances
print.im

Print Brief Details of an Image
eem

Exponential Energy Marks
ord.family

Ord Interaction Process Family
Gmulti

Marked Nearest Neighbour Distance Function
subset.psp

Extract Subset of Line Segment Pattern
allstats

Calculate four standard summary functions of a point pattern.
eval.fasp

Evaluate Expression Involving Function Arrays
lengths.psp

Lengths of Line Segments
quadscheme

Generate a Quadrature Scheme from a Point Pattern
print.quad

Print a Quadrature Scheme
hist.im

Histogram of Pixel Values in an Image
bdist.pixels

Distance to Boundary of Window
angles.psp

Orientation Angles of Line Segments
shift.ppp

Apply Vector Translation To Point Pattern
rmhstart

Determine Initial State for Metropolis-Hastings Simulation.
rlabel

Random Re-Labelling of Point Pattern
progressreport

Print Progress Reports
is.owin

Test Whether An Object Is A Window
is.multitype

Test whether Object is Multitype
rmhmodel.ppm

Interpret Fitted Model for Metropolis-Hastings Simulation.
bounding.box.xy

Convex Hull of Points
plot.psp

plot a Spatial Line Segment Pattern
ppm

Fit Point Process Model to Data
longleaf

Longleaf Pines Point Pattern
pcf.ppp

Pair Correlation Function of Point Pattern
is.marked

Test Whether Marks Are Present
spatstat-deprecated

Deprecated spatstat functions
nncross

Nearest Neighbour in Another Point Pattern
inside.owin

Test Whether Points Are Inside A Window
identify.ppp

Identify Points in a Point Pattern
rGaussPoisson

Simulate Gauss-Poisson Process
residualspaper

Data and Code From JRSS Discussion Paper on Residuals
markstat

Summarise Marks in Every Neighbourhood in a Point Pattern
marktable

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

Hybrid Geyer Point Process Model
rMatClust

Simulate Matern Cluster Process
redwoodfull

California Redwoods Point Pattern (Entire Dataset)
Strauss

The Strauss Point Process Model
Softcore

The Soft Core Point Process Model
plot.ppm

plot a Fitted Point Process Model
compatible.im

Test Whether Two Pixel Images Are Compatible
selfcrossing.psp

Crossing Points in a Line Segment Pattern
simulate.kppm

Simulate a fitted cluster point process model.
rshift

Random Shift
shift.owin

Apply Vector Translation To Window
Jcross

Multitype J Function (i-to-j)
rSSI

Simulate Simple Sequential Inhibition
rThomas

Simulate Thomas Process
Kinhom

Inhomogeneous K-function
cells

Biological Cells Point Pattern
stieltjes

Compute Integral of Function Against Cumulative Distribution
rsyst

Simulate systematic random point pattern
spruces

Spruces Point Pattern
spokes

Spokes pattern of dummy points
trim.rectangle

Cut margins from rectangle
tiles

Extract List of Tiles in a Tessellation
shift.psp

Apply Vector Translation To Line Segment Pattern
runifpoint

Generate N Uniform Random Points
StraussHard

The Strauss / Hard Core Point Process Model
rNeymanScott

Simulate Neyman-Scott Process
summary.ppm

Summarizing a Fitted Point Process Model
compatible.fasp

Test Whether Two Function Arrays Are Compatible
simdat

Simulated Point Pattern
square

Square Window
solutionset

Evaluate Logical Expression Involving Pixel Images and Return Region Where Expression is True
crossdist.ppp

Pairwise distances between two different point patterns
update.ppm

Update a Fitted Point Process Model
Ldot

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

Summary of a Line Segment Pattern Dataset
spatstat-internal

Internal spatstat functions
Linhom

L-function
ppp

Create a Point Pattern
plot.kppm

Plot a fitted cluster point process
ripras

Estimate window from points alone
plot.owin

Plot a Spatial Window
shift.im

Apply Vector Translation To Pixel Image
append.psp

Combine Two Line Segment Patterns
plot.im

Plot a Pixel Image
thomas.estK

Fit the Thomas Point Process by Minimum Contrast
as.owin

Convert Data To Class owin
betacells

Beta Ganglion Cells in Cat Retina
summary.listof

Summary of a List of Things
rmpoint

Generate N Random Multitype Points
setmarks

Set or Reset the Marks in a Point Pattern
copper

Berman-Huntington points and lines data
[.tess

Extract or Replace Subset of Tessellation
concatxy

Concatenate x,y Coordinate Vectors
rmhmodel.list

Define Point Process Model for Metropolis-Hastings Simulation.
superimpose

Superimpose Several Point Patterns
subset.splitppp

Extract or Replace Sub-Patterns
pairdist.ppp

Pairwise distances
plot.ppp

plot a Spatial Point Pattern
unitname

Name for Unit of Length
quadrat.test

Chi-Squared Dispersion Test for Spatial Point Pattern Based on Quadrat Counts
density.splitppp

Kernel Smoothed Intensity of Split Point Pattern
subset.im

Extract Subset of Image
split.ppp

Divide Point Pattern into Sub-patterns
is.multitype.ppm

Test Whether A Point Process Model is Multitype
quantile.im

Sample Quantiles of Pixel Image
rmhmodel.default

Build Point Process Model for Metropolis-Hastings Simulation.
subset.fv

Extract Subset of Function Values
humberside

Humberside Data on Childhood Leukaemia and Lymphoma
rescale.owin

Convert Window to Another Unit of Length
print.ppp

Print Brief Details of a Point Pattern Dataset
rpoint

Generate N Random Points
raster.x

Cartesian Coordinates for a Pixel Raster
is.marked.ppm

Test Whether A Point Process Model is Marked
project2segment

Move Point To Nearest Line
areadiff

Difference of Disc Areas
kaplan.meier

Kaplan-Meier Estimator using Histogram Data
rthin

Random Thinning
rescale.im

Convert Pixel Image to Another Unit of Length
union.quad

Union of Data and Dummy Points
crossing.psp

Crossing Points of Two Line Segment Patterns
rshift.splitppp

Randomly Shift a List of Point Patterns
predict.ppm

Prediction from a Fitted Point Process Model
erode.owin

Erode a Window
ponderosa

Ponderosa Pine Tree Point Pattern
nztrees

New Zealand Trees Point Pattern
is.subset.owin

Determine Whether One Window is Contained In Another
pppmatching.object

Class of Point Matchings
ppp.object

Class of Point Patterns
quad.ppm

Extract Quadrature Scheme Used to Fit a Point Process Model
urkiola

Urkiola Woods Point Pattern
pixellate

Convert Point Pattern to Pixel Image
predict.kppm

Prediction from a Fitted Cluster Point Process Model
with.fv

Evaluate an Expression in a Function Table
rpoispp

Generate Poisson Point Pattern
runifdisc

Generate N Uniform Random Points in a Disc
Kcross.inhom

Inhomogeneous Cross K Function
summary.ppp

Summary of a Point Pattern Dataset
distmap.psp

Distance Map of Line Segment Pattern
rotate.psp

Rotate a Line Segment Pattern
subset.ppp

Extract or Replace Subset of Point Pattern
plot.listof

Plot a List of Things
summary.owin

Summary of a Spatial Window
update.kppm

Update a Fitted Cluster Point Process Model
Lcross

Multitype L-function (cross-type)
harmonic

Basis for Harmonic Functions
[.quad

Subset of Quadrature Scheme
nbfires

Point Patterns of New Brunswick Forest Fires
split.im

Divide Image Into Sub-images
subset.fasp

Extract Subset of Function Array
summary.splitppp

Summary of a Split Point Pattern
vcov.ppm

Variance-Covariance Matrix for a Fitted Point Process Model
rescale.psp

Convert Line Segment Pattern to Another Unit of Length
Iest

Estimate the I-function
subset.listof

Extract or Replace Subset of a List of Things
rshift.ppp

Randomly Shift a Point Pattern
is.im

Test Whether An Object Is A Pixel Image
owin.object

Class owin
rotate.ppp

Rotate a Point Pattern
suffstat

Sufficient Statistic of Point Process Model
rpoisline

Generate Poisson Random Line Process
unmark

Remove Marks
reduced.sample

Reduced Sample Estimator using Histogram Data
smooth.ppp

Spatial smoothing of observations at irregular points
tess

Create a Tessellation
unique.ppp

Extract Unique Points from a Spatial Point Pattern
swedishpines

Swedish Pines Point Pattern
anova.ppm

ANOVA for Fitted Point Process Models
superimposePSP

Superimpose Several Line Segment Patterns
corners

Corners of a rectangle
redwood

California Redwoods Point Pattern (Ripley's Subset)
as.im

Convert to Pixel Image
vertices

Vertices of a Window
spatstat.options

Internal Options in Spatstat Package