Learn R Programming

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

spatstat (version 1.14-2)

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

17,668

Version

1.14-2

License

GPL (>= 2)

Maintainer

Adrian Baddeley

Last Published

March 22nd, 2025

Functions in spatstat (1.14-2)

rStrauss

Perfect Simulation of the Strauss Process
persp.im

Perspective Plot of Pixel Image
rotate.owin

Rotate a Window
plot.splitppp

Plot a List of Point Patterns
rthin

Random Thinning
rshift.ppp

Randomly Shift a Point Pattern
pairdist

Pairwise distances
quad.object

Class of Quadrature Schemes
pcf.fasp

Pair Correlation Function obtained from array of K functions
shift.im

Apply Vector Translation To Pixel Image
plot.tess

Plot a tessellation
quadscheme

Generate a Quadrature Scheme from a Point Pattern
rNeymanScott

Simulate Neyman-Scott Process
subset.im

Extract Subset of Image
rescale.psp

Convert Line Segment Pattern to Another Unit of Length
rlinegrid

Generate grid of parallel lines with random displacement
plot.psp

plot a Spatial Line Segment Pattern
redwoodfull

California Redwoods Point Pattern (Entire Dataset)
plot.ppm

plot a Fitted Point Process Model
pairdist.psp

Pairwise distances between line segments
ponderosa

Ponderosa Pine Tree Point Pattern
rjitter

Random Perturbation of a Point Pattern
[.tess

Extract or Replace Subset of Tessellation
pixelquad

Quadrature Scheme Based on Pixel Grid
spruces

Spruces Point Pattern
print.quad

Print a Quadrature Scheme
runifpoint

Generate N Uniform Random Points
summary.im

Summarizing a Pixel Image
progressreport

Print Progress Reports
subset.ppp

Extract or Replace Subset of Point Pattern
unique.ppp

Extract Unique Points from a Spatial Point Pattern
psp

Create a Line Segment Pattern
predict.kppm

Prediction from a Fitted Cluster Point Process Model
print.ppm

Print a Fitted Point Process Model
rMaternII

Simulate Matern Model II
subset.listof

Extract or Replace Subset of a List of Things
rescue.rectangle

Convert Window Back To Rectangle
summary.listof

Summary of a List of Things
reduced.sample

Reduced Sample Estimator using Histogram Data
ripras

Estimate window from points alone
rescale.ppp

Convert Point Pattern to Another Unit of Length
plot.quad

plot a Spatial Quadrature Scheme
rescale.im

Convert Pixel Image to Another Unit of Length
rmh.default

Simulate Point Process Models using the Metropolis-Hastings Algorithm.
plot.listof

Plot a List of Things
update.ppm

Update a Fitted Point Process Model
rmhmodel.ppm

Interpret Fitted Model for Metropolis-Hastings Simulation.
rmhmodel.default

Build Point Process Model for Metropolis-Hastings Simulation.
plot.plotppm

Plot a plotppm Object Created by plot.ppm
summary.splitppp

Summary of a Split Point Pattern
rshift

Random Shift
plot.fasp

Plot a Function Array
plot.owin

Plot a Spatial Window
pcf

Pair Correlation Function
thomas.estK

Fit the Thomas Point Process by Minimum Contrast
residualspaper

Data and Code From JRSS Discussion Paper on Residuals
psp.object

Class of Line Segment Patterns
rmhstart

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

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

Subset of Quadrature Scheme
shift.psp

Apply Vector Translation To Line Segment Pattern
rpoint

Generate N Random Points
unmark

Remove Marks from a Marked Point Pattern
rSSI

Simulate Simple Sequential Inhibition
rMatClust

Simulate Matern Cluster Process
pcf.fv

Pair Correlation Function obtained from K Function
pairwise.family

Pairwise Interaction Process Family
shift.ppp

Apply Vector Translation To Point Pattern
rThomas

Simulate Thomas Process
rescale

Convert dataset to another unit of length
rotate.ppp

Rotate a Point Pattern
urkiola

Urkiola Woods Point Pattern
subsetget.im

Reset Values in Subset of Image
plot.ppp

plot a Spatial Point Pattern
rpoispp

Generate Poisson Point Pattern
plot.hyperframe

Plot Entries in a Hyperframe
pairsat.family

Saturated Pairwise Interaction Point Process Family
vcov.ppm

Variance-Covariance Matrix for a Fitted Point Process Model
ppm.object

Class of Fitted Point Process Models
spatstat.options

Internal Options in Spatstat Package
rmpoispp

Generate Multitype Poisson Point Pattern
simdat

Simulated Point Pattern
pairdist.ppp

Pairwise distances
plot.kppm

Plot a fitted cluster point process
reach

Interaction Distance of a Point Process
subset.psp

Extract Subset of Line Segment Pattern
summary.ppm

Summarizing a Fitted Point Process Model
pppdist

Distance Between Two Point Patterns
summary.psp

Summary of a Line Segment Pattern Dataset
superimpose

Superimpose Several Point Patterns
rescale.owin

Convert Window to Another Unit of Length
runifdisc

Generate N Uniform Random Points in a Disc
simulate.kppm

Simulate a fitted cluster point process model.
trim.rectangle

Cut margins from rectangle
print.ppp

Print Brief Details of a Point Pattern Dataset
ppp.object

Class of Point Patterns
scanpp

Read Point Pattern From Data File
residuals.ppm

Residuals for Fitted Point Process Model
pppmatching

Create a Point Matching
plot.fv

Plot Function Valuesn
unitname

Name for Unit of Length
rshift.splitppp

Randomly Shift a List of Point Patterns
profilepl

Profile Maximum Pseudolikelihood
rmhmodel

Define Point Process Model for Metropolis-Hastings Simulation.
setcov

Set Covariance of a Window
print.owin

Print Brief Details of a Spatial Window
setmarks

Set or Reset the Marks in a Point Pattern
rstrat

Simulate Stratified Random Point Pattern
plot.im

Plot a Pixel Image
rsyst

Simulate systematic random point pattern
rGaussPoisson

Simulate Gauss-Poisson Process
qqplot.ppm

Q-Q Plot of Residuals from Fitted Point Process Model
print.im

Print Brief Details of an Image
with.fv

Evaluate an Expression in a Function Table
suffstat

Sufficient Statistic of Point Process Model
ppm

Fit Point Process Model to Data
swedishpines

Swedish Pines Point Pattern
quantile.im

Sample Quantiles of Pixel Image
shift.owin

Apply Vector Translation To Window
rMaternI

Simulate Matern Model I
rmpoint

Generate N Random Multitype Points
union.quad

Union of Data and Dummy Points
tiles

Extract List of Tiles in a Tessellation
redwood

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

Spatial smoothing of observations at irregular points
stieltjes

Compute Integral of Function Against Cumulative Distribution
rmhmodel.list

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

Extract Subset of Function Values
rshift.psp

Randomly Shift a Line Segment Pattern
rcell

Simulate Baddeley-Silverman Cell Process
predict.ppm

Prediction from a Fitted Point Process Model
rmhcontrol

Set Control Parameters for Metropolis-Hastings Algorithm.
quadratcount

Quadrat counting for a point pattern
rlabel

Random Re-Labelling of Point Pattern
rotate.psp

Rotate a Line Segment Pattern
rpoisline

Generate Poisson Random Line Process
Geyer

Geyer's Saturation Point Process Model
summary.quad

Summarizing a Quadrature Scheme
shift

Apply Vector Translation
update.kppm

Update a Fitted Cluster Point Process Model
spokes

Spokes pattern of dummy points
summary.ppp

Summary of a Point Pattern Dataset
pcf.ppp

Pair Correlation Function of Point Pattern
vertices

Vertices of a Window
square

Square Window
selfcrossing.psp

Crossing Points in a Line Segment Pattern
subset.splitppp

Extract or Replace Sub-Patterns
Kmulti

Marked K-Function
raster.x

Cartesian Coordinates for a Pixel Raster
Strauss

The Strauss Point Process Model
Jdot

Multitype J Function (i-to-any)
rmh.ppm

Simulate from a Fitted Point Process Model
ppp

Create a Point Pattern
density.splitppp

Kernel Smoothed Intensity of Split Point Pattern
solutionset

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

L-function
blur

Apply Gaussian Blur to a Pixel Image
subset.fasp

Extract Subset of Function Array
dilate.owin

Dilate a Window
bdist.pixels

Distance to Boundary of Window
rotate

Rotate
bdist.points

Distance to Boundary of Window
Jcross

Multitype J Function (i-to-j)
harmonic

Basis for Harmonic Functions
kppm

Fit cluster point process model
pcfcross

Multitype pair correlation function
is.multitype

Test whether Object is Multitype
is.owin

Test Whether An Object Is A Window
nnwhich

Nearest neighbour
Fest

Estimate the empty space function F
clickppp

Interactively Add Points
AreaInter

The Area Interaction Point Process Model
pppmatching.object

Class of Point Matchings
quad.ppm

Extract Quadrature Scheme Used to Fit a Point Process Model
kstest.ppm

Kolmogorov-Smirnov Test for Point Process Model
as.im

Convert to Pixel Image
PairPiece

The Piecewise Constant Pairwise Interaction Point Process Model
disc

Circular Window
distmap.psp

Distance Map of Line Segment Pattern
Kmeasure

Reduced Second Moment Measure
lansing

Lansing Woods Point Pattern
ewcdf

Weighted Empirical Cumulative Distribution Function
as.matrix.im

Convert Pixel Image to Matrix
affine.owin

Apply Affine Transformation To Window
Gdot

Multitype Nearest Neighbour Distance Function (i-to-any)
default.dummy

Generate a Default Pattern of Dummy Points
Poisson

Poisson Point Process Model
longleaf

Longleaf Pines Point Pattern
allstats

Calculate four standard summary functions of a point pattern.
OrdThresh

Ord's Interaction model
nearest.raster.point

Find Pixel Nearest to a Given Point
Kinhom

Inhomogeneous K-function
eroded.areas

Areas of Morphological Erosions
affine.ppp

Apply Affine Transformation To Point Pattern
compatible.fasp

Test Whether Two Function Arrays Are Compatible
by.ppp

Apply a Function to a Point Pattern Broken Down by Factor
as.ppp

Convert Data To Class ppp
corners

Corners of a rectangle
nbfires

Point Patterns of New Brunswick Forest Fires
Jmulti

Marked J Function
bramblecanes

Hutchings' Bramble Canes data
as.rectangle

Window Frame
as.data.frame.ppp

Coerce Point Pattern to a Data Frame
nndist

Nearest neighbour distances
Linhom

L-function
owin.object

Class owin
Ord

Generic Ord Interaction model
quadrat.test

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

Simulate point patterns using the Metropolis-Hastings algorithm.
Saturated

Saturated Pairwise Interaction model
concatxy

Concatenate x,y Coordinate Vectors
spatstat-deprecated

Deprecated spatstat functions
anemones

Beadlet Anemones Data
cut.im

Convert Pixel Image from Numeric to Factor
cut.ppp

Classify Points in a Point Pattern
levelset

Level Set of a Pixel Image
data.ppm

Extract Original Data from a Fitted Point Process Model
ord.family

Ord Interaction Process Family
split.ppp

Divide Point Pattern into Sub-patterns
eval.fasp

Evaluate Expression Involving Function Arrays
diameter

Diameter of a Window
markstat

Summarise Marks in Every Neighbourhood in a Point Pattern
eval.hyper

Evaluate an Expression in Each Row of a Hyperframe
hamster

Aherne's hamster tumour data
inforder.family

Infinite Order Interaction Family
affine

Apply Affine Transformation
is.marked.ppp

Test Whether A Point Pattern is Marked
nndist.psp

Nearest neighbour distances between line segments
density.psp

Kernel Smoothing of Line Segment Pattern
bounding.box

Bounding Box of a Window or Point Pattern
summary.owin

Summary of a Spatial Window
cells

Biological Cells Point Pattern
tess

Create a Tessellation
eem

Exponential Energy Marks
Kest.fft

K-function using FFT
is.marked

Test Whether Marks Are Present
StraussHard

The Strauss / Hard Core Point Process Model
bei

Tropical rain forest trees
dummy.ppm

Extract Dummy Points Used to Fit a Point Process Model
coef.ppm

Coefficients of Fitted Point Process Model
Jest

Estimate the J-function
expand.owin

Expand Window By Factor
ganglia

Beta Ganglion Cells in Cat Retina, Old Version
fv.object

Data Frames of Function Values
spatstat-internal

Internal spatstat functions
logLik.ppm

Log Likelihood for Poisson Point Process Model
Kest

K-function
finpines

Pine saplings in Finland.
identify.ppp

Identify Points in a Point Pattern
multiplicity.ppp

Count Multiplicity of Duplicate Points
marktable

Tabulate Marks in Neighbourhood of Every Point in a Point Pattern
lgcp.estK

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

Test Whether A Point Process Model is Multitype
area.owin

Area of a Window
gridweights

Compute Quadrature Weights Based on Grid Counts
applynbd

Apply Function to Every Neighbourhood in a Point Pattern
Gcross

Multitype Nearest Neighbour Distance Function (i-to-j)
angles.psp

Orientation Angles of Line Segments
Kdot

Multitype K Function (i-to-any)
erode.owin

Erode a Window
is.marked.ppm

Test Whether A Point Process Model is Marked
spatstat

The Spatstat Package
compatible.fv

Test Whether Two Function Objects Are Compatible
contour.im

Contour plot of pixel image
envelope

Simulation envelopes of summary function
demopat

Artificial Data Point Pattern
MultiStraussHard

The Multitype/Hard Core Strauss Point Process Model
eval.fv

Evaluate Expression Involving Functions
Lcross

Multitype L-function (cross-type)
lurking

Lurking variable plot
letterR

Window in Shape of Letter R
duplicated.ppp

Determine Duplicated Points in a Spatial Point Pattern
dirichlet

Dirichlet Tessellation of Point Pattern
MultiStrauss

The Multitype Strauss Point Process Model
DiggleGratton

Diggle-Gratton model
affine.psp

Apply Affine Transformation To Line Segment Pattern
is.im

Test Whether An Object Is A Pixel Image
gridcentres

Rectangular grid of points
as.psp

Convert Data To Class psp
alltypes

Calculate Summary Statistic for All Types in a Multitype Point Pattern
model.matrix.ppm

Extract Design Matrix from Point Process Model
anova.ppm

ANOVA for Fitted Point Process Models
crossdist.default

Pairwise distances between two different sets of points
amacrine

Hughes' Amacrine Cell Data
as.mask

Pixel Image Approximation of a Window
ants

Harkness-Isham ants' nests data
humberside

Humberside Data on Childhood Leukaemia and Lymphoma
pairdist.default

Pairwise distances
gpc2owin

Convert Polygonal Region into Different Format
append.psp

Combine Two Line Segment Patterns
Softcore

The Soft Core Point Process Model
areadiff

Difference of Disc Areas
endpoints.psp

Endpoints of Line Segment Pattern
Iest

Estimate the I-function
clickpoly

Interactively Define a Polygon
SatPiece

Piecewise Constant Saturated Pairwise Interaction Point Process Model
clarkevans

Clark and Evans Aggregation Index
Pairwise

Generic Pairwise Interaction model
is.subset.owin

Determine Whether One Window is Contained In Another
fitted.ppm

Fitted Conditional Intensity for Point Process Model
dirichlet.weights

Compute Quadrature Weights Based on Dirichlet Tessellation
betacells

Beta Ganglion Cells in Cat Retina
convexhull.xy

Convex Hull of Points
bounding.box.xy

Convex Hull of Points
fasp.object

Function Arrays for Spatial Patterns
copper

Berman-Huntington points and lines data
crossdist

Pairwise distances
interp.im

Interpolate a Pixel Image
nztrees

New Zealand Trees Point Pattern
matclust.estK

Fit the Matern Cluster Point Process by Minimum Contrast
BadGey

Hybrid Geyer Point Process Model
chorley

Chorley-Ribble Cancer Data
distmap

Distance Map
discretise

Safely Convert Point Pattern Window to Binary Mask
is.multitype.ppp

Test Whether A Point Pattern is Multitype
diagnose.ppm

Diagnostic Plots for Fitted Point Process Model
im

Create a Pixel Image Object
hyperframe

Hyper Data Frame
compatible.im

Test Whether Two Pixel Images Are Compatible
hist.im

Histogram of Pixel Values in an Image
distmap.ppp

Distance Map of Point Pattern
distmap.owin

Distance Map of Window
km.rs

Kaplan-Meier and Reduced Sample Estimator using Histograms
crossdist.ppp

Pairwise distances between two different point patterns
density.ppp

Kernel Smoothed Intensity of Point Pattern
intersect.owin

Intersection or Union of Two Windows
Gest

Nearest Neighbour Distance Function G
inside.owin

Test Whether Points Are Inside A Window
Kdot.inhom

Inhomogeneous Multitype K Dot Function
midpoints.psp

Midpoints of Line Segment Pattern
Ldot

Multitype L-function (i-to-any)
complement.owin

Take Complement of a Window
kaplan.meier

Kaplan-Meier Estimator using Histogram Data
lengths.psp

Lengths of Line Segments
effectfun

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

Create a Window
im.object

Class of Images
LennardJones

The Lennard-Jones Potential
crossing.psp

Crossing Points of Two Line Segment Patterns
nncorr

Nearest-Neighbour Correlation of Marked Point Pattern
markcorr

Mark Correlation Function
nncross

Nearest Neighbour in Another Point Pattern
Gmulti

Marked Nearest Neighbour Distance Function
mean.im

Mean Pixel Value in an Image
as.owin

Convert Data To Class owin
Kcross.inhom

Inhomogeneous Cross K Function
Kcross

Multitype K Function (Cross-type)
centroid.owin

Centroid of a window
model.images

Compute Images of Constructed Covariates
crossdist.psp

Pairwise distances between two different line segment patterns
eval.im

Evaluate Expression Involving Pixel Images
delaunay

Delaunay Triangulation of Point Pattern
is.ppp

Test Whether An Object Is A Point Pattern
localK

Neighbourhood density function
fitin.ppm

Extract the Interaction from a Fitted Point Process Model
matchingdist

Distance for a Point Pattern Matching
is.ppm

Test Whether An Object Is A Fitted Point Process Model
japanesepines

Japanese Pines Point Pattern
murchison

Murchison gold deposits
mincontrast

Method of Minimum Contrast