Learn R Programming

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

spatstat (version 1.14-1)

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

License

GPL (>= 2)

Maintainer

Adrian Baddeley

Last Published

March 22nd, 2025

Functions in spatstat (1.14-1)

Gmulti

Marked Nearest Neighbour Distance Function
Linhom

L-function
Jdot

Multitype J Function (i-to-any)
LennardJones

The Lennard-Jones Potential
Softcore

The Soft Core Point Process Model
Poisson

Poisson Point Process Model
anova.ppm

ANOVA for Fitted Point Process Models
as.rectangle

Window Frame
allstats

Calculate four standard summary functions of a point pattern.
Jcross

Multitype J Function (i-to-j)
as.data.frame.ppp

Coerce Point Pattern to a Data Frame
spatstat

The Spatstat Package
Kdot.inhom

Inhomogeneous Multitype K Dot Function
duplicated.ppp

Determine Duplicated Points in a Spatial Point Pattern
Geyer

Geyer's Saturation Point Process Model
diameter

Diameter of a Window
Kest

K-function
Kcross

Multitype K Function (Cross-type)
AreaInter

The Area Interaction Point Process Model
bounding.box.xy

Convex Hull of Points
anemones

Beadlet Anemones Data
crossdist.ppp

Pairwise distances between two different point patterns
complement.owin

Take Complement of a Window
Saturated

Saturated Pairwise Interaction model
affine.owin

Apply Affine Transformation To Window
Gcross

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

L-function
applynbd

Apply Function to Every Neighbourhood in a Point Pattern
is.multitype

Test whether Object is Multitype
Kinhom

Inhomogeneous K-function
clickppp

Interactively Add Points
as.mask

Pixel Image Approximation of a Window
dummy.ppm

Extract Dummy Points Used to Fit a Point Process Model
DiggleGratton

Diggle-Gratton model
delaunay

Delaunay Triangulation of Point Pattern
density.splitppp

Kernel Smoothed Intensity of Split Point Pattern
Kest.fft

K-function using FFT
demopat

Artificial Data Point Pattern
amacrine

Hughes' Amacrine Cell Data
BadGey

Hybrid Geyer Point Process Model
MultiStraussHard

The Multitype/Hard Core Strauss Point Process Model
distmap

Distance Map
concatxy

Concatenate x,y Coordinate Vectors
affine

Apply Affine Transformation
Jmulti

Marked J Function
distmap.ppp

Distance Map of Point Pattern
bdist.pixels

Distance to Boundary of Window
Gdot

Multitype Nearest Neighbour Distance Function (i-to-any)
density.ppp

Kernel Smoothed Intensity of Point Pattern
Kmeasure

Reduced Second Moment Measure
append.psp

Combine Two Line Segment Patterns
bdist.points

Distance to Boundary of Window
eval.hyper

Evaluate an Expression in Each Row of a Hyperframe
OrdThresh

Ord's Interaction model
Lcross

Multitype L-function (cross-type)
angles.psp

Orientation Angles of Line Segments
ants

Harkness-Isham ants' nests data
inforder.family

Infinite Order Interaction Family
coef.ppm

Coefficients of Fitted Point Process Model
eval.fasp

Evaluate Expression Involving Function Arrays
Jest

Estimate the J-function
dirichlet

Dirichlet Tessellation of Point Pattern
marktable

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

Apply Affine Transformation To Line Segment Pattern
disc

Circular Window
SatPiece

Piecewise Constant Saturated Pairwise Interaction Point Process Model
is.ppp

Test Whether An Object Is A Point Pattern
StraussHard

The Strauss / Hard Core Point Process Model
bounding.box

Bounding Box of a Window or Point Pattern
fitted.ppm

Fitted Conditional Intensity for Point Process Model
affine.ppp

Apply Affine Transformation To Point Pattern
Iest

Estimate the I-function
clickpoly

Interactively Define a Polygon
as.im

Convert to Pixel Image
discretise

Safely Convert Point Pattern Window to Binary Mask
as.owin

Convert Data To Class owin
centroid.owin

Centroid of a window
identify.ppp

Identify Points in a Point Pattern
compatible.im

Test Whether Two Pixel Images Are Compatible
kstest.ppm

Kolmogorov-Smirnov Test for Point Process Model
data.ppm

Extract Original Data from a Fitted Point Process Model
lgcp.estK

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

Test Whether An Object Is A Fitted Point Process Model
as.matrix.im

Convert Pixel Image to Matrix
spatstat-internal

Internal spatstat functions
clarkevans

Clark and Evans Aggregation Index
crossdist.default

Pairwise distances between two different sets of points
MultiStrauss

The Multitype Strauss Point Process Model
areadiff

Difference of Disc Areas
chorley

Chorley-Ribble Cancer Data
fv.object

Data Frames of Function Values
eval.im

Evaluate Expression Involving Pixel Images
expand.owin

Expand Window By Factor
ewcdf

Weighted Empirical Cumulative Distribution Function
plot.tess

Plot a tessellation
Kcross.inhom

Inhomogeneous Cross K Function
compatible.fasp

Test Whether Two Function Arrays Are Compatible
logLik.ppm

Log Likelihood for Poisson Point Process Model
crossdist.psp

Pairwise distances between two different line segment patterns
rNeymanScott

Simulate Neyman-Scott Process
markcorr

Mark Correlation Function
eroded.areas

Areas of Morphological Erosions
pairdist

Pairwise distances
erode.owin

Erode a Window
pairdist.psp

Pairwise distances between line segments
nndist

Nearest neighbour distances
copper

Berman-Huntington points and lines data
is.subset.owin

Determine Whether One Window is Contained In Another
rescale

Convert dataset to another unit of length
nncorr

Nearest-Neighbour Correlation of Marked Point Pattern
reach

Interaction Distance of a Point Process
rotate.owin

Rotate a Window
endpoints.psp

Endpoints of Line Segment Pattern
betacells

Beta Ganglion Cells in Cat Retina
kppm

Fit cluster point process model
distmap.psp

Distance Map of Line Segment Pattern
gridweights

Compute Quadrature Weights Based on Grid Counts
quadratcount

Quadrat counting for a point pattern
rotate.ppp

Rotate a Point Pattern
Ldot

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

Humberside Data on Childhood Leukaemia and Lymphoma
psp

Create a Line Segment Pattern
model.matrix.ppm

Extract Design Matrix from Point Process Model
quantile.im

Sample Quantiles of Pixel Image
longleaf

Longleaf Pines Point Pattern
rotate

Rotate
crossdist

Pairwise distances
im.object

Class of Images
mincontrast

Method of Minimum Contrast
quadscheme

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

Test Whether A Point Process Model is Marked
pairsat.family

Saturated Pairwise Interaction Point Process Family
distmap.owin

Distance Map of Window
cut.ppp

Classify Points in a Point Pattern
rescue.rectangle

Convert Window Back To Rectangle
diagnose.ppm

Diagnostic Plots for Fitted Point Process Model
fasp.object

Function Arrays for Spatial Patterns
lengths.psp

Lengths of Line Segments
update.ppm

Update a Fitted Point Process Model
cells

Biological Cells Point Pattern
km.rs

Kaplan-Meier and Reduced Sample Estimator using Histograms
plot.plotppm

Plot a plotppm Object Created by plot.ppm
nearest.raster.point

Find Pixel Nearest to a Given Point
rmh.ppm

Simulate from a Fitted Point Process Model
owin.object

Class owin
effectfun

Compute Fitted Effect of a Spatial Covariate in a Point Process Model
crossing.psp

Crossing Points of Two Line Segment Patterns
predict.ppm

Prediction from a Fitted Point Process Model
cut.im

Convert Pixel Image from Numeric to Factor
ppp.object

Class of Point Patterns
gridcentres

Rectangular grid of points
nbfires

Point Patterns of New Brunswick Forest Fires
runifpoint

Generate N Uniform Random Points
matchingdist

Distance for a Point Pattern Matching
pcf

Pair Correlation Function
PairPiece

The Piecewise Constant Pairwise Interaction Point Process Model
envelope

Simulation envelopes of summary function
print.owin

Print Brief Details of a Spatial Window
rsyst

Simulate systematic random point pattern
rstrat

Simulate Stratified Random Point Pattern
print.ppm

Print a Fitted Point Process Model
spatstat.options

Internal Options in Spatstat Package
pppmatching.object

Class of Point Matchings
plot.fasp

Plot a Function Array
plot.splitppp

Plot a List of Point Patterns
is.marked

Test Whether Marks Are Present
density.psp

Kernel Smoothing of Line Segment Pattern
matclust.estK

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

Plot Entries in a Hyperframe
shift

Apply Vector Translation
as.ppp

Convert Data To Class ppp
japanesepines

Japanese Pines Point Pattern
redwoodfull

California Redwoods Point Pattern (Entire Dataset)
nncross

Nearest Neighbour in Another Point Pattern
midpoints.psp

Midpoints of Line Segment Pattern
im

Create a Pixel Image Object
residuals.ppm

Residuals for Fitted Point Process Model
adaptive.density

Intensity Estimate of Point Pattern Using Tessellation
rescale.psp

Convert Line Segment Pattern to Another Unit of Length
ponderosa

Ponderosa Pine Tree Point Pattern
finpines

Pine saplings in Finland.
rmhmodel.ppm

Interpret Fitted Model for Metropolis-Hastings Simulation.
plot.listof

Plot a List of Things
subset.psp

Extract Subset of Line Segment Pattern
print.quad

Print a Quadrature Scheme
rMatClust

Simulate Matern Cluster Process
Fest

Estimate the empty space function F
rshift.splitppp

Randomly Shift a List of Point Patterns
multiplicity.ppp

Count Multiplicity of Duplicate Points
Ord

Generic Ord Interaction model
as.data.frame.psp

Coerce Line Segment Pattern to a Data Frame
owin

Create a Window
raster.x

Cartesian Coordinates for a Pixel Raster
Strauss

The Strauss Point Process Model
as.psp

Convert Data To Class psp
pairwise.family

Pairwise Interaction Process Family
reduced.sample

Reduced Sample Estimator using Histogram Data
profilepl

Profile Maximum Pseudolikelihood
subset.splitppp

Extract or Replace Sub-Patterns
bramblecanes

Hutchings' Bramble Canes data
alltypes

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

Divide Point Pattern into Sub-patterns
progressreport

Print Progress Reports
inside.owin

Test Whether Points Are Inside A Window
spatstat-deprecated

Deprecated spatstat functions
rotate.psp

Rotate a Line Segment Pattern
rMaternI

Simulate Matern Model I
Pairwise

Generic Pairwise Interaction model
blur

Apply Gaussian Blur to a Pixel Image
is.owin

Test Whether An Object Is A Window
kaplan.meier

Kaplan-Meier Estimator using Histogram Data
shift.ppp

Apply Vector Translation To Point Pattern
spokes

Spokes pattern of dummy points
Kdot

Multitype K Function (i-to-any)
subset.fasp

Extract Subset of Function Array
rmhmodel

Define Point Process Model for Metropolis-Hastings Simulation.
subsetget.im

Reset Values in Subset of Image
update.kppm

Update a Fitted Cluster Point Process Model
interp.im

Interpolate a Pixel Image
residualspaper

Data and Code From JRSS Discussion Paper on Residuals
stieltjes

Compute Integral of Function Against Cumulative Distribution
rmpoispp

Generate Multitype Poisson Point Pattern
is.multitype.ppp

Test Whether A Point Pattern is Multitype
contour.im

Contour plot of pixel image
dirichlet.weights

Compute Quadrature Weights Based on Dirichlet Tessellation
Gest

Nearest Neighbour Distance Function G
rescale.owin

Convert Window to Another Unit of Length
hist.im

Histogram of Pixel Values in an Image
convexhull.xy

Convex Hull of Points
plot.kppm

Plot a fitted cluster point process
lurking

Lurking variable plot
summary.quad

Summarizing a Quadrature Scheme
setcov

Set Covariance of a Window
plot.owin

Plot a Spatial Window
localK

Neighbourhood density function
compatible.fv

Test Whether Two Function Objects Are Compatible
nnwhich

Nearest neighbour
harmonic

Basis for Harmonic Functions
selfcrossing.psp

Crossing Points in a Line Segment Pattern
shift.im

Apply Vector Translation To Pixel Image
by.im

Apply Function to Image Broken Down by Factor
quad.ppm

Extract Quadrature Scheme Used to Fit a Point Process Model
lansing

Lansing Woods Point Pattern
runifdisc

Generate N Uniform Random Points in a Disc
pcf.fv

Pair Correlation Function obtained from K Function
ppm

Fit Point Process Model to Data
ripras

Estimate window from points alone
print.ppp

Print Brief Details of a Point Pattern Dataset
solutionset

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

Name for Unit of Length
superimpose

Superimpose Several Point Patterns
subset.fv

Extract Subset of Function Values
rshift

Random Shift
shift.owin

Apply Vector Translation To Window
gpc2owin

Convert Polygonal Region into Different Format
quad.object

Class of Quadrature Schemes
dilate.owin

Dilate a Window
summary.im

Summarizing a Pixel Image
[.tess

Extract or Replace Subset of Tessellation
miplot

Morishita Index Plot
vcov.ppm

Variance-Covariance Matrix for a Fitted Point Process Model
rmhstart

Determine Initial State for Metropolis-Hastings Simulation.
markstat

Summarise Marks in Every Neighbourhood in a Point Pattern
area.owin

Area of a Window
rStrauss

Perfect Simulation of the Strauss Process
ganglia

Beta Ganglion Cells in Cat Retina, Old Version
Kmulti

Marked K-Function
rlabel

Random Re-Labelling of Point Pattern
bei

Tropical rain forest trees
letterR

Window in Shape of Letter R
pppdist

Distance Between Two Point Patterns
summary.ppp

Summary of a Point Pattern Dataset
hyperframe

Hyper Data Frame
print.psp

Print Brief Details of a Line Segment Pattern Dataset
pairdist.default

Pairwise distances
plot.fv

Plot Function Valuesn
ppp

Create a Point Pattern
summary.psp

Summary of a Line Segment Pattern Dataset
is.im

Test Whether An Object Is A Pixel Image
eval.fv

Evaluate Expression Involving Functions
default.dummy

Generate a Default Pattern of Dummy Points
swedishpines

Swedish Pines Point Pattern
rpoispp

Generate Poisson Point Pattern
[.quad

Subset of Quadrature Scheme
rmhmodel.list

Define Point Process Model for Metropolis-Hastings Simulation.
simdat

Simulated Point Pattern
rcell

Simulate Baddeley-Silverman Cell Process
rSSI

Simulate Simple Sequential Inhibition
corners

Corners of a rectangle
opening.owin

Morphological Opening of a Window
quadrat.test

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

Create a Point Matching
rMaternII

Simulate Matern Model II
ppm.object

Class of Fitted Point Process Models
pcf.ppp

Pair Correlation Function of Point Pattern
subset.listof

Extract or Replace Subset of a List of Things
hamster

Aherne's hamster tumour data
model.images

Compute Images of Constructed Covariates
pcfcross

Multitype pair correlation function
incircle

Find Largest Circle Inside Window
intersect.owin

Intersection or Union of Two Windows
eem

Exponential Energy Marks
is.marked.ppp

Test Whether A Point Pattern is Marked
smooth.ppp

Spatial smoothing of observations at irregular points
subset.im

Extract Subset of Image
unique.ppp

Extract Unique Points from a Spatial Point Pattern
rThomas

Simulate Thomas Process
nndist.psp

Nearest neighbour distances between line segments
summary.listof

Summary of a List of Things
plot.ppp

plot a Spatial Point Pattern
setmarks

Set or Reset the Marks in a Point Pattern
levelset

Level Set of a Pixel Image
quadratresample

Resample a Point Pattern by Resampling Quadrats
psp.object

Class of Line Segment Patterns
suffstat

Sufficient Statistic of Point Process Model
project2segment

Move Point To Nearest Line
redwood

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

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

Simulate Gauss-Poisson Process
qqplot.ppm

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

Quadrature Scheme Based on Pixel Grid
is.multitype.ppm

Test Whether A Point Process Model is Multitype
rjitter

Random Perturbation of a Point Pattern
rpoisline

Generate Poisson Random Line Process
plot.quad

plot a Spatial Quadrature Scheme
rlinegrid

Generate grid of parallel lines with random displacement
rmhmodel.default

Build Point Process Model for Metropolis-Hastings Simulation.
mean.im

Mean Pixel Value in an Image
nztrees

New Zealand Trees Point Pattern
rshift.psp

Randomly Shift a Line Segment Pattern
union.quad

Union of Data and Dummy Points
predict.kppm

Prediction from a Fitted Cluster Point Process Model
intersect.tess

Intersection of Two Tessellations
shift.psp

Apply Vector Translation To Line Segment Pattern
rpoint

Generate N Random Points
summary.owin

Summary of a Spatial Window
fitin.ppm

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

Plot a Pixel Image
with.fv

Evaluate an Expression in a Function Table
tess

Create a Tessellation
quadrat.test.splitppp

Chi-Squared Test of CSR for Split Point Pattern
rmh.default

Simulate Point Process Models using the Metropolis-Hastings Algorithm.
persp.im

Perspective Plot of Pixel Image
plot.psp

plot a Spatial Line Segment Pattern
rmhcontrol

Set Control Parameters for Metropolis-Hastings Algorithm.
pointsOnLines

Place Points Evenly Along Specified Lines
plot.ppm

plot a Fitted Point Process Model
summary.ppm

Summarizing a Fitted Point Process Model
rescale.ppp

Convert Point Pattern to Another Unit of Length
murchison

Murchison gold deposits
ord.family

Ord Interaction Process Family
rmpoint

Generate N Random Multitype Points
pcf.fasp

Pair Correlation Function obtained from array of K functions
trim.rectangle

Cut margins from rectangle
print.im

Print Brief Details of an Image
urkiola

Urkiola Woods Point Pattern
quadrats

Divide Region into Quadrats
rescale.im

Convert Pixel Image to Another Unit of Length
simulate.kppm

Simulate a fitted cluster point process model.
as.tess

Convert Data To Tessellation
rthin

Random Thinning
pairdist.ppp

Pairwise distances
scanpp

Read Point Pattern From Data File
rmh

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

Randomly Shift a Point Pattern
subset.ppp

Extract or Replace Subset of Point Pattern
spruces

Spruces Point Pattern
rpoisppOnLines

Generate Poisson Point Pattern on Line Segments
tiles

Extract List of Tiles in a Tessellation
fryplot

Fry Plot of Point Pattern
square

Square Window
summary.splitppp

Summary of a Split Point Pattern
vertices

Vertices of a Window
nearestsegment

Find Line Segment Nearest to Each Point
runifpointOnLines

Generate N Uniform Random Points On Line Segments
thomas.estK

Fit the Thomas Point Process by Minimum Contrast
split.im

Divide Image Into Sub-images
superimposePSP

Superimpose Several Line Segment Patterns
unmark

Remove Marks from a Marked Point Pattern
closing.owin

Morphological Closing of a Window
pixellate

Convert Point Pattern to Pixel Image