Learn R Programming

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

spatstat (version 1.14-3)

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

License

GPL (>= 2)

Maintainer

Adrian Baddeley

Last Published

March 22nd, 2025

Functions in spatstat (1.14-3)

murchison

Murchison gold deposits
lurking

Lurking variable plot
clickppp

Interactively Add Points
pcf.ppp

Pair Correlation Function of Point Pattern
contour.im

Contour plot of pixel image
nncorr

Nearest-Neighbour Correlation of Marked Point Pattern
is.marked

Test Whether Marks Are Present
as.im

Convert to Pixel Image
Kcross.inhom

Inhomogeneous Cross K Function
angles.psp

Orientation Angles of Line Segments
coef.ppm

Coefficients of Fitted Point Process Model
owin.object

Class owin
MultiStrauss

The Multitype Strauss Point Process Model
hist.im

Histogram of Pixel Values in an Image
model.images

Compute Images of Constructed Covariates
as.mask

Pixel Image Approximation of a Window
mincontrast

Method of Minimum Contrast
Lest

L-function
rMatClust

Simulate Matern Cluster Process
Strauss

The Strauss Point Process Model
pairdist.psp

Pairwise distances between line segments
Gest

Nearest Neighbour Distance Function G
letterR

Window in Shape of Letter R
BadGey

Hybrid Geyer Point Process Model
Gmulti

Marked Nearest Neighbour Distance Function
rpoisline

Generate Poisson Random Line Process
centroid.owin

Centroid of a window
SatPiece

Piecewise Constant Saturated Pairwise Interaction Point Process Model
matchingdist

Distance for a Point Pattern Matching
setmarks

Set or Reset the Marks in a Point Pattern
midpoints.psp

Midpoints of Line Segment Pattern
AreaInter

The Area Interaction Point Process Model
duplicated.ppp

Determine Duplicated Points in a Spatial Point Pattern
Kest

K-function
nndist.psp

Nearest neighbour distances between line segments
lansing

Lansing Woods Point Pattern
delaunay

Delaunay Triangulation of Point Pattern
compatible.im

Test Whether Two Pixel Images Are Compatible
kaplan.meier

Kaplan-Meier Estimator using Histogram Data
is.marked.ppm

Test Whether A Point Process Model is Marked
rotate.ppp

Rotate a Point Pattern
markstat

Summarise Marks in Every Neighbourhood in a Point Pattern
pcf.fv

Pair Correlation Function obtained from K Function
compatible.fasp

Test Whether Two Function Arrays Are Compatible
Pairwise

Generic Pairwise Interaction model
kstest.ppm

Kolmogorov-Smirnov Test for Point Process Model
Kcross

Multitype K Function (Cross-type)
plot.listof

Plot a List of Things
model.matrix.ppm

Extract Design Matrix from Point Process Model
Kmeasure

Reduced Second Moment Measure
subset.psp

Extract Subset of Line Segment Pattern
default.dummy

Generate a Default Pattern of Dummy Points
longleaf

Longleaf Pines Point Pattern
fitin.ppm

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

Erode a Window
ants

Harkness-Isham ants' nests data
pairdist.ppp

Pairwise distances
fv.object

Data Frames of Function Values
concatxy

Concatenate x,y Coordinate Vectors
compatible.fv

Test Whether Two Function Objects Are Compatible
Ord

Generic Ord Interaction model
is.multitype.ppp

Test Whether A Point Pattern is Multitype
rescue.rectangle

Convert Window Back To Rectangle
bdist.pixels

Distance to Boundary of Window
Jest

Estimate the J-function
betacells

Beta Ganglion Cells in Cat Retina
cut.im

Convert Pixel Image from Numeric to Factor
spatstat-deprecated

Deprecated spatstat functions
OrdThresh

Ord's Interaction model
crossdist.ppp

Pairwise distances between two different point patterns
allstats

Calculate four standard summary functions of a point pattern.
Jcross

Multitype J Function (i-to-j)
plot.ppm

plot a Fitted Point Process Model
discretise

Safely Convert Point Pattern Window to Binary Mask
crossing.psp

Crossing Points of Two Line Segment Patterns
PairPiece

The Piecewise Constant Pairwise Interaction Point Process Model
clickpoly

Interactively Define a Polygon
Linhom

L-function
identify.ppp

Identify Points in a Point Pattern
density.psp

Kernel Smoothing of Line Segment Pattern
is.im

Test Whether An Object Is A Pixel Image
nztrees

New Zealand Trees Point Pattern
lengths.psp

Lengths of Line Segments
Poisson

Poisson Point Process Model
area.owin

Area of a Window
Kinhom

Inhomogeneous K-function
Ldot

Multitype L-function (i-to-any)
eroded.areas

Areas of Morphological Erosions
eem

Exponential Energy Marks
gridcentres

Rectangular grid of points
pairdist

Pairwise distances
bramblecanes

Hutchings' Bramble Canes data
quad.object

Class of Quadrature Schemes
simulate.kppm

Simulate a fitted cluster point process model.
multiplicity.ppp

Count Multiplicity of Duplicate Points
LennardJones

The Lennard-Jones Potential
Saturated

Saturated Pairwise Interaction model
plot.owin

Plot a Spatial Window
ewcdf

Weighted Empirical Cumulative Distribution Function
nbfires

Point Patterns of New Brunswick Forest Fires
distmap

Distance Map
endpoints.psp

Endpoints of Line Segment Pattern
density.ppp

Kernel Smoothed Intensity of Point Pattern
plot.fv

Plot Function Valuesn
crossdist

Pairwise distances
plot.quad

plot a Spatial Quadrature Scheme
subset.splitppp

Extract or Replace Sub-Patterns
Lcross

Multitype L-function (cross-type)
inside.owin

Test Whether Points Are Inside A Window
quad.ppm

Extract Quadrature Scheme Used to Fit a Point Process Model
rThomas

Simulate Thomas Process
Kdot

Multitype K Function (i-to-any)
dummy.ppm

Extract Dummy Points Used to Fit a Point Process Model
Jdot

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

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

Divide Region into Quadrats
copper

Berman-Huntington points and lines data
interp.im

Interpolate a Pixel Image
profilepl

Profile Maximum Pseudolikelihood
rotate.psp

Rotate a Line Segment Pattern
residuals.ppm

Residuals for Fitted Point Process Model
summary.ppp

Summary of a Point Pattern Dataset
summary.im

Summarizing a Pixel Image
square

Square Window
pcf.fasp

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

Pairwise distances
plot.plotppm

Plot a plotppm Object Created by plot.ppm
gridweights

Compute Quadrature Weights Based on Grid Counts
plot.kppm

Plot a fitted cluster point process
predict.ppm

Prediction from a Fitted Point Process Model
japanesepines

Japanese Pines Point Pattern
plot.im

Plot a Pixel Image
distmap.owin

Distance Map of Window
pcfcross

Multitype pair correlation function
as.data.frame.ppp

Coerce Point Pattern to a Data Frame
summary.quad

Summarizing a Quadrature Scheme
nnwhich

Nearest neighbour
rescale.owin

Convert Window to Another Unit of Length
pppmatching.object

Class of Point Matchings
Kmulti

Marked K-Function
as.owin

Convert Data To Class owin
hamster

Aherne's hamster tumour data
markcorr

Mark Correlation Function
spatstat.options

Internal Options in Spatstat Package
is.multitype.ppm

Test Whether A Point Process Model is Multitype
intersect.owin

Intersection or Union of Two Windows
affine

Apply Affine Transformation
rcell

Simulate Baddeley-Silverman Cell Process
quadratcount

Quadrat counting for a point pattern
quadrat.test

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

Generate N Random Multitype Points
quadratresample

Resample a Point Pattern by Resampling Quadrats
envelope

Simulation envelopes of summary function
levelset

Level Set of a Pixel Image
rSSI

Simulate Simple Sequential Inhibition
pixelquad

Quadrature Scheme Based on Pixel Grid
residualspaper

Data and Code From JRSS Discussion Paper on Residuals
dirichlet.weights

Compute Quadrature Weights Based on Dirichlet Tessellation
corners

Corners of a rectangle
rjitter

Random Perturbation of a Point Pattern
rsyst

Simulate systematic random point pattern
plot.psp

plot a Spatial Line Segment Pattern
summary.ppm

Summarizing a Fitted Point Process Model
ppm.object

Class of Fitted Point Process Models
bei

Tropical rain forest trees
density.splitppp

Kernel Smoothed Intensity of Split Point Pattern
pppmatching

Create a Point Matching
redwoodfull

California Redwoods Point Pattern (Entire Dataset)
raster.x

Cartesian Coordinates for a Pixel Raster
is.ppm

Test Whether An Object Is A Fitted Point Process Model
runifpoint

Generate N Uniform Random Points
ponderosa

Ponderosa Pine Tree Point Pattern
predict.kppm

Prediction from a Fitted Cluster Point Process Model
psp.object

Class of Line Segment Patterns
bounding.box

Bounding Box of a Window or Point Pattern
append.psp

Combine Two Line Segment Patterns
nearest.raster.point

Find Pixel Nearest to a Given Point
diameter

Diameter of a Window
MultiStraussHard

The Multitype/Hard Core Strauss Point Process Model
spruces

Spruces Point Pattern
subset.listof

Extract or Replace Subset of a List of Things
reach

Interaction Distance of a Point Process
applynbd

Apply Function to Every Neighbourhood in a Point Pattern
print.psp

Print Brief Details of a Line Segment Pattern Dataset
tess

Create a Tessellation
ripras

Estimate window from points alone
nncross

Nearest Neighbour in Another Point Pattern
alltypes

Calculate Summary Statistic for All Types in a Multitype Point Pattern
convexhull.xy

Convex Hull of Points
marktable

Tabulate Marks in Neighbourhood of Every Point in a Point Pattern
expand.owin

Expand Window By Factor
progressreport

Print Progress Reports
lgcp.estK

Fit a Log-Gaussian Cox Point Process by Minimum Contrast
summary.owin

Summary of a Spatial Window
[.tess

Extract or Replace Subset of Tessellation
rNeymanScott

Simulate Neyman-Scott Process
ord.family

Ord Interaction Process Family
demopat

Artificial Data Point Pattern
plot.tess

Plot a tessellation
as.rectangle

Window Frame
shift.im

Apply Vector Translation To Pixel Image
kppm

Fit cluster point process model
km.rs

Kaplan-Meier and Reduced Sample Estimator using Histograms
ppm

Fit Point Process Model to Data
rmhmodel.list

Define Point Process Model for Metropolis-Hastings Simulation.
print.quad

Print a Quadrature Scheme
rMaternII

Simulate Matern Model II
amacrine

Hughes' Amacrine Cell Data
reduced.sample

Reduced Sample Estimator using Histogram Data
Kest.fft

K-function using FFT
trim.rectangle

Cut margins from rectangle
hyperframe

Hyper Data Frame
rStrauss

Perfect Simulation of the Strauss Process
tiles

Extract List of Tiles in a Tessellation
shift.owin

Apply Vector Translation To Window
anova.ppm

ANOVA for Fitted Point Process Models
owin

Create a Window
rotate.owin

Rotate a Window
Geyer

Geyer's Saturation Point Process Model
print.im

Print Brief Details of an Image
suffstat

Sufficient Statistic of Point Process Model
logLik.ppm

Log Likelihood for Poisson Point Process Model
cut.ppp

Classify Points in a Point Pattern
with.fv

Evaluate an Expression in a Function Table
qqplot.ppm

Q-Q Plot of Residuals from Fitted Point Process Model
update.ppm

Update a Fitted Point Process Model
plot.fasp

Plot a Function Array
rpoispp

Generate Poisson Point Pattern
unique.ppp

Extract Unique Points from a Spatial Point Pattern
persp.im

Perspective Plot of Pixel Image
rotate

Rotate
rpoint

Generate N Random Points
as.matrix.im

Convert Pixel Image to Matrix
distmap.ppp

Distance Map of Point Pattern
print.ppp

Print Brief Details of a Point Pattern Dataset
harmonic

Basis for Harmonic Functions
scanpp

Read Point Pattern From Data File
pppdist

Distance Between Two Point Patterns
fasp.object

Function Arrays for Spatial Patterns
im.object

Class of Images
spatstat

The Spatstat Package
Iest

Estimate the I-function
unitname

Name for Unit of Length
unmark

Remove Marks from a Marked Point Pattern
inforder.family

Infinite Order Interaction Family
rmpoispp

Generate Multitype Poisson Point Pattern
disc

Circular Window
redwood

California Redwoods Point Pattern (Ripley's Subset)
rescale

Convert dataset to another unit of length
fitted.ppm

Fitted Conditional Intensity for Point Process Model
update.kppm

Update a Fitted Cluster Point Process Model
rescale.ppp

Convert Point Pattern to Another Unit of Length
subset.fasp

Extract Subset of Function Array
anemones

Beadlet Anemones Data
rmhmodel.default

Build Point Process Model for Metropolis-Hastings Simulation.
ppp

Create a Point Pattern
eval.fv

Evaluate Expression Involving Functions
rlabel

Random Re-Labelling of Point Pattern
is.ppp

Test Whether An Object Is A Point Pattern
ganglia

Beta Ganglion Cells in Cat Retina, Old Version
superimpose

Superimpose Several Point Patterns
quadscheme

Generate a Quadrature Scheme from a Point Pattern
spokes

Spokes pattern of dummy points
Kdot.inhom

Inhomogeneous Multitype K Dot Function
stieltjes

Compute Integral of Function Against Cumulative Distribution
runifdisc

Generate N Uniform Random Points in a Disc
as.ppp

Convert Data To Class ppp
crossdist.default

Pairwise distances between two different sets of points
rshift.psp

Randomly Shift a Line Segment Pattern
setcov

Set Covariance of a Window
crossdist.psp

Pairwise distances between two different line segment patterns
DiggleGratton

Diggle-Gratton model
smooth.ppp

Spatial smoothing of observations at irregular points
eval.im

Evaluate Expression Involving Pixel Images
diagnose.ppm

Diagnostic Plots for Fitted Point Process Model
rshift.ppp

Randomly Shift a Point Pattern
rmh.ppm

Simulate from a Fitted Point Process Model
vcov.ppm

Variance-Covariance Matrix for a Fitted Point Process Model
clarkevans

Clark and Evans Aggregation Index
Gcross

Multitype Nearest Neighbour Distance Function (i-to-j)
[.quad

Subset of Quadrature Scheme
subsetget.im

Reset Values in Subset of Image
rstrat

Simulate Stratified Random Point Pattern
simdat

Simulated Point Pattern
is.multitype

Test whether Object is Multitype
humberside

Humberside Data on Childhood Leukaemia and Lymphoma
blur

Apply Gaussian Blur to a Pixel Image
split.ppp

Divide Point Pattern into Sub-patterns
areadiff

Difference of Disc Areas
affine.psp

Apply Affine Transformation To Line Segment Pattern
as.psp

Convert Data To Class psp
summary.listof

Summary of a List of Things
chorley

Chorley-Ribble Cancer Data
is.marked.ppp

Test Whether A Point Pattern is Marked
effectfun

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

Union of Data and Dummy Points
dirichlet

Dirichlet Tessellation of Point Pattern
urkiola

Urkiola Woods Point Pattern
rescale.psp

Convert Line Segment Pattern to Another Unit of Length
affine.ppp

Apply Affine Transformation To Point Pattern
StraussHard

The Strauss / Hard Core Point Process Model
rthin

Random Thinning
pairwise.family

Pairwise Interaction Process Family
is.owin

Test Whether An Object Is A Window
thomas.estK

Fit the Thomas Point Process by Minimum Contrast
rmhmodel.ppm

Interpret Fitted Model for Metropolis-Hastings Simulation.
Softcore

The Soft Core Point Process Model
rshift.splitppp

Randomly Shift a List of Point Patterns
ppp.object

Class of Point Patterns
rmhstart

Determine Initial State for Metropolis-Hastings Simulation.
im

Create a Pixel Image Object
rmhcontrol

Set Control Parameters for Metropolis-Hastings Algorithm.
shift

Apply Vector Translation
selfcrossing.psp

Crossing Points in a Line Segment Pattern
dilate.owin

Dilate a Window
print.ppm

Print a Fitted Point Process Model
subset.ppp

Extract or Replace Subset of Point Pattern
eval.fasp

Evaluate Expression Involving Function Arrays
distmap.psp

Distance Map of Line Segment Pattern
shift.ppp

Apply Vector Translation To Point Pattern
subset.fv

Extract Subset of Function Values
matclust.estK

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

Plot Entries in a Hyperframe
localK

Neighbourhood density function
psp

Create a Line Segment Pattern
spatstat-internal

Internal spatstat functions
pairsat.family

Saturated Pairwise Interaction Point Process Family
summary.psp

Summary of a Line Segment Pattern Dataset
finpines

Pine saplings in Finland.
vertices

Vertices of a Window
subset.im

Extract Subset of Image
rmhmodel

Define Point Process Model for Metropolis-Hastings Simulation.
Fest

Estimate the empty space function F
plot.ppp

plot a Spatial Point Pattern
Jmulti

Marked J Function
print.owin

Print Brief Details of a Spatial Window
solutionset

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

Simulate Matern Model I
summary.splitppp

Summary of a Split Point Pattern
bounding.box.xy

Convex Hull of Points
gpc2owin

Convert Polygonal Region into Different Format
Gdot

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

Random Shift
affine.owin

Apply Affine Transformation To Window
rmh

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

Sample Quantiles of Pixel Image
plot.splitppp

Plot a List of Point Patterns
nndist

Nearest neighbour distances
rlinegrid

Generate grid of parallel lines with random displacement
mean.im

Mean Pixel Value in an Image
swedishpines

Swedish Pines Point Pattern
bdist.points

Distance to Boundary of Window
shift.psp

Apply Vector Translation To Line Segment Pattern
rescale.im

Convert Pixel Image to Another Unit of Length
complement.owin

Take Complement of a Window
data.ppm

Extract Original Data from a Fitted Point Process Model
is.subset.owin

Determine Whether One Window is Contained In Another
pcf

Pair Correlation Function
cells

Biological Cells Point Pattern
eval.hyper

Evaluate an Expression in Each Row of a Hyperframe
rGaussPoisson

Simulate Gauss-Poisson Process
rmh.default

Simulate Point Process Models using the Metropolis-Hastings Algorithm.