Learn R Programming

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

spatstat (version 1.12-4)

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.12-4

License

GPL (>= 2)

Maintainer

Adrian Baddeley

Last Published

March 22nd, 2025

Functions in spatstat (1.12-4)

matclust.estK

Fit the Matern Cluster Point Process by Minimum Contrast
Kdot

Multitype K Function (i-to-any)
distmap.ppp

Distance Map of Point Pattern
Kcross.inhom

Inhomogeneous Cross K Function
Kinhom

Inhomogeneous K-function
multiplicity.ppp

Count Multiplicity of Duplicate Points
ppm

Fit Point Process Model to Data
Iest

Estimate the I-function
angles.psp

Orientation Angles of Line Segments
quad.ppm

Extract Quadrature Scheme Used to Fit a Point Process Model
clickppp

Interactively Add Points
amacrine

Hughes' Amacrine Cell Data
copper

Berman-Huntington points and lines data
quantile.im

Sample Quantiles of Pixel Image
levelset

Level Set of a Pixel Image
crossdist.psp

Pairwise distances between two different line segment patterns
as.psp

Convert Data To Class psp
diagnose.ppm

Diagnostic Plots for Fitted Point Process Model
Jdot

Multitype J Function (i-to-any)
Softcore

The Soft Core Point Process Model
Kmeasure

Reduced Second Moment Measure
im.object

Class of Images
plot.splitppp

Plot a List of Point Patterns
Fest

Estimate the empty space function F
StraussHard

The Strauss / Hard Core Point Process Model
allstats

Calculate four standard summary functions of a point pattern.
Kest.fft

K-function using FFT
rStrauss

Perfect Simulation of the Strauss Process
affine.owin

Apply Affine Transformation To Window
bei

Tropical rain forest trees
LennardJones

The Lennard-Jones Potential
ewcdf

Weighted Empirical Cumulative Distribution Function
ants

Harkness-Isham ants' nests data
anova.ppm

ANOVA for Fitted Point Process Models
as.data.frame.ppp

Coerce Point Pattern to a Data Frame
affine.ppp

Apply Affine Transformation To Point Pattern
bounding.box

Bounding Box of a Window or Point Pattern
anemones

Beadlet Anemones Data
endpoints.psp

Endpoints of Line Segment Pattern
compatible.im

Test Whether Two Pixel Images Are Compatible
clickpoly

Interactively Define a Polygon
distmap

Distance Map
owin.object

Class owin
data.ppm

Extract Original Data from a Fitted Point Process Model
harmonic

Basis for Harmonic Functions
as.rectangle

Window Frame
contour.im

Contour plot of pixel image
markstat

Summarise Marks in Every Neighbourhood in a Point Pattern
nndist

Nearest neighbour distances
bdist.pixels

Distance to Boundary of Window
rmhmodel.default

Build Point Process Model for Metropolis-Hastings Simulation.
psp.object

Class of Line Segment Patterns
inside.owin

Test Whether Points Are Inside A Window
rmhcontrol

Set Control Parameters for Metropolis-Hastings Algorithm.
centroid.owin

Centroid of a window
coef.ppm

Coefficients of Fitted Point Process Model
summary.quad

Summarizing a Quadrature Scheme
nnwhich

Nearest neighbour
Gcross

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

The Spatstat Package
persp.im

Perspective Plot of Pixel Image
corners

Corners of a rectangle
subset.fv

Extract Subset of Function Values
fitted.ppm

Fitted Conditional Intensity for Point Process Model
bramblecanes

Hutchings' Bramble Canes data
pcf.ppp

Pair Correlation Function of Point Pattern
is.multitype

Test whether Object is Multitype
MultiStrauss

The Multitype Strauss Point Process Model
japanesepines

Japanese Pines Point Pattern
eval.hyper

Evaluate an Expression in Each Row of a Hyperframe
Strauss

The Strauss Point Process Model
hist.im

Histogram of Pixel Values in an Image
compatible.fv

Test Whether Two Function Objects Are Compatible
demopat

Artificial Data Point Pattern
clarkevans

Clark and Evans Aggregation Index
cut.im

Convert Pixel Image from Numeric to Factor
eem

Exponential Energy Marks
thomas.estK

Fit the Thomas Point Process by Minimum Contrast
localK

Neighbourhood density function
ganglia

Beta Ganglion Cells in Cat Retina, Old Version
rMaternII

Simulate Matern Model II
Gmulti

Marked Nearest Neighbour Distance Function
rmh

Simulate point patterns using the Metropolis-Hastings algorithm.
matchingdist

Distance for a Point Pattern Matching
summary.splitppp

Summary of a Split Point Pattern
is.ppm

Test Whether An Object Is A Fitted Point Process Model
Jest

Estimate the J-function
as.ppp

Convert Data To Class ppp
pairdist.default

Pairwise distances
nncross

Nearest Neighbour in Another Point Pattern
nbfires

Point Patterns of New Brunswick Forest Fires
spatstat-deprecated

Deprecated spatstat functions
DiggleGratton

Diggle-Gratton model
is.marked.ppm

Test Whether A Point Process Model is Marked
affine.psp

Apply Affine Transformation To Line Segment Pattern
im

Create a Pixel Image Object
ks.test.ppm

Kolmogorov-Smirnov Test for Point Process Model
Jmulti

Marked J Function
interp.im

Interpolate a Pixel Image
bounding.box.xy

Convex Hull of Points
as.im

Convert to Pixel Image
print.ppm

Print a Fitted Point Process Model
duplicated.ppp

Determine Duplicated Points in a Spatial Point Pattern
print.psp

Print Brief Details of a Line Segment Pattern Dataset
nncorr

Nearest-Neighbour Correlation of Marked Point Pattern
print.quad

Print a Quadrature Scheme
convexhull.xy

Convex Hull of Points
plot.owin

Plot a Spatial Window
envelope

Simulation envelopes of summary function
Kcross

Multitype K Function (Cross-type)
OrdThresh

Ord's Interaction model
plot.listof

Plot a List of Things
Kmulti

Marked K-Function
rSSI

Simulate Simple Sequential Inhibition
Pairwise

Generic Pairwise Interaction model
nndist.psp

Nearest neighbour distances between line segments
eval.im

Evaluate Expression Involving Pixel Images
pppdist

Distance Between Two Point Patterns
crossdist

Pairwise distances
Poisson

Poisson Point Process Model
rotate.ppp

Rotate a Point Pattern
lengths.psp

Lengths of Line Segments
plot.ppp

plot a Spatial Point Pattern
nearest.raster.point

Find Pixel Nearest to a Given Point
rcell

Simulate Baddeley-Silverman Cell Process
ppm.object

Class of Fitted Point Process Models
gridcentres

Rectangular grid of points
Kest

K-function
density.psp

Kernel Smoothing of Line Segment Pattern
Saturated

Saturated Pairwise Interaction model
rshift

Random Shift
rshift.splitppp

Randomly Shift a List of Point Patterns
Jcross

Multitype J Function (i-to-j)
humberside

Humberside Data on Childhood Leukaemia and Lymphoma
rescue.rectangle

Convert Window Back To Rectangle
plot.im

Plot a Pixel Image
Kdot.inhom

Inhomogeneous Multitype K Dot Function
selfcrossing.psp

Crossing Points in a Line Segment Pattern
plot.hyperframe

Plot Entries in a Hyperframe
rMaternI

Simulate Matern Model I
Lest

L-function
psp

Create a Line Segment Pattern
residualspaper

Data and Code From JRSS Discussion Paper on Residuals
Ord

Generic Ord Interaction model
gridweights

Compute Quadrature Weights Based on Grid Counts
applynbd

Apply Function to Every Neighbourhood in a Point Pattern
rlabel

Random Re-Labelling of Point Pattern
qqplot.ppm

Q-Q Plot of Residuals from Fitted Point Process Model
plot.fv

Plot Function Valuesn
rmh.default

Simulate Point Process Models using the Metropolis-Hastings Algorithm.
rescale.owin

Convert Window to Another Unit of Length
rThomas

Simulate Thomas Process
as.matrix.im

Convert Pixel Image to Matrix
longleaf

Longleaf Pines Point Pattern
subset.listof

Extract or Replace Subset of a List of Things
Gest

Nearest Neighbour Distance Function G
spruces

Spruces Point Pattern
as.owin

Convert Data To Class owin
density.splitppp

Kernel Smoothed Intensity of Split Point Pattern
dilate.owin

Dilate a Window
rmhmodel

Define Point Process Model for Metropolis-Hastings Simulation.
mincontrast

Method of Minimum Contrast
bdist.points

Distance to Boundary of Window
suffstat

Sufficient Statistic of Point Process Model
append.psp

Combine Two Line Segment Patterns
ppp

Create a Point Pattern
redwoodfull

California Redwoods Point Pattern (Entire Dataset)
quadratcount

Quadrat counting for a point pattern
hamster

Aherne's hamster tumour data
rotate.psp

Rotate a Line Segment Pattern
crossdist.ppp

Pairwise distances between two different point patterns
dirichlet.weights

Compute Quadrature Weights Based on Dirichlet Tessellation
subset.splitppp

Extract or Replace Sub-Patterns
smooth.ppp

Spatial smoothing of observations at irregular points
update.ppm

Update a Fitted Point Process Model
reduced.sample

Reduced Sample Estimator using Histogram Data
simdat

Simulated Point Pattern
discretise

Safely Convert Point Pattern Window to Binary Mask
redwood

California Redwoods Point Pattern (Ripley's Subset)
spatstat.options

Internal Options in Spatstat Package
nztrees

New Zealand Trees Point Pattern
concatxy

Concatenate x,y Coordinate Vectors
summary.psp

Summary of a Line Segment Pattern Dataset
is.marked

Test Whether Marks Are Present
fasp.object

Function Arrays for Spatial Patterns
summary.ppp

Summary of a Point Pattern Dataset
solutionset

Evaluate Logical Expression Involving Pixel Images and Return Region Where Expression is True
dummy.ppm

Extract Dummy Points Used to Fit a Point Process Model
MultiStraussHard

The Multitype/Hard Core Strauss Point Process Model
rmpoispp

Generate Multitype Poisson Point Pattern
subset.ppp

Extract or Replace Subset of Point Pattern
pairdist

Pairwise distances
subset.psp

Extract Subset of Line Segment Pattern
spatstat-internal

Internal spatstat functions
summary.ppm

Summarizing a Fitted Point Process Model
rotate.owin

Rotate a Window
complement.owin

Take Complement of a Window
PairPiece

The Piecewise Constant Pairwise Interaction Point Process Model
as.mask

Pixel Image Approximation of a Window
is.multitype.ppp

Test Whether A Point Pattern is Multitype
fitin.ppm

Extract the Interaction from a Fitted Point Process Model
rstrat

Simulate Stratified Random Point Pattern
distmap.psp

Distance Map of Line Segment Pattern
area.owin

Area of a Window
midpoints.psp

Midpoints of Line Segment Pattern
rshift.psp

Randomly Shift a Line Segment Pattern
intersect.owin

Intersection or Union of Two Windows
ppp.object

Class of Point Patterns
chorley

Chorley-Ribble Cancer Data
rNeymanScott

Simulate Neyman-Scott Process
ripras

Estimate window from points alone
shift

Apply Vector Translation
fv.object

Data Frames of Function Values
lansing

Lansing Woods Point Pattern
rMatClust

Simulate Matern Cluster Process
rpoisline

Generate Poisson Random Line Process
km.rs

Kaplan-Meier and Reduced Sample Estimator using Histograms
default.dummy

Generate a Default Pattern of Dummy Points
plot.ppm

plot a Fitted Point Process Model
unique.ppp

Extract Unique Points from a Spatial Point Pattern
rsyst

Simulate systematic random point pattern
is.subset.owin

Determine Whether One Window is Contained In Another
profilepl

Profile Maximum Pseudolikelihood
setmarks

Set or Reset the Marks in a Point Pattern
lurking

Lurking variable plot
pairdist.psp

Pairwise distances between line segments
scanpp

Read Point Pattern From Data File
identify.ppp

Identify Points in a Point Pattern
is.multitype.ppm

Test Whether A Point Process Model is Multitype
print.im

Print Brief Details of an Image
shift.ppp

Apply Vector Translation To Point Pattern
shift.psp

Apply Vector Translation To Line Segment Pattern
is.im

Test Whether An Object Is A Pixel Image
runifpoint

Generate N Uniform Random Points
vertices

Vertices of a Window
eroded.areas

Areas of Morphological Erosions
swedishpines

Swedish Pines Point Pattern
kaplan.meier

Kaplan-Meier Estimator using Histogram Data
pcf

Pair Correlation Function
letterR

Window in Shape of Letter R
affine

Apply Affine Transformation
pairsat.family

Saturated Pairwise Interaction Point Process Family
quadrat.test

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

Biological Cells Point Pattern
lgcp.estK

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

Convert dataset to another unit of length
rmhstart

Determine Initial State for Metropolis-Hastings Simulation.
square

Square Window
pairdist.ppp

Pairwise distances
markcorr

Mark Correlation Function
predict.ppm

Prediction from a Fitted Point Process Model
plot.psp

plot a Spatial Line Segment Pattern
raster.x

Cartesian Coordinates for a Pixel Raster
plot.quad

plot a Spatial Quadrature Scheme
setcov

Set Covariance of a Window
rmpoint

Generate N Random Multitype Points
summary.im

Summarizing a Pixel Image
rlinegrid

Generate grid of parallel lines with random displacement
rotate

Rotate
rshift.ppp

Randomly Shift a Point Pattern
split.ppp

Divide Point Pattern into Sub-patterns
print.owin

Print Brief Details of a Spatial Window
ord.family

Ord Interaction Process Family
shift.im

Apply Vector Translation To Pixel Image
owin

Create a Window
pcf.fv

Pair Correlation Function obtained from K Function
superimpose

Superimpose Several Point Patterns
plot.fasp

Plot a Function Array
unmark

Remove Marks from a Marked Point Pattern
progressreport

Print Progress Reports
rescale.ppp

Convert Point Pattern to Another Unit of Length
rmhmodel.list

Define Point Process Model for Metropolis-Hastings Simulation.
unitname

Name for Unit of Length
union.quad

Union of Data and Dummy Points
reach

Interaction Distance of a Point Process
shift.owin

Apply Vector Translation To Window
vcov.ppm

Variance-Covariance Matrix for a Fitted Point Process Model
spokes

Spokes pattern of dummy points
summary.owin

Summary of a Spatial Window
subset.fasp

Extract Subset of Function Array
subsetget.im

Reset Values in Subset of Image
rmh.ppm

Simulate from a Fitted Point Process Model
crossing.psp

Crossing Points of Two Line Segment Patterns
density.ppp

Kernel Smoothed Intensity of Point Pattern
distmap.owin

Distance Map of Window
Geyer

Geyer's Saturation Point Process Model
alltypes

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

Erode a Window
expand.owin

Expand Window By Factor
eval.fv

Evaluate Expression Involving Functions
diameter

Diameter of a Window
is.marked.ppp

Test Whether A Point Pattern is Marked
is.owin

Test Whether An Object Is A Window
logLik.ppm

Log Likelihood for Poisson Point Process Model
pcf.fasp

Pair Correlation Function obtained from array of K functions
ponderosa

Ponderosa Pine Tree Point Pattern
print.ppp

Print Brief Details of a Point Pattern Dataset
quadscheme

Generate a Quadrature Scheme from a Point Pattern
rpoint

Generate N Random Points
rescale.psp

Convert Line Segment Pattern to Another Unit of Length
rthin

Random Thinning
trim.rectangle

Cut margins from rectangle
plot.plotppm

Plot a plotppm Object Created by plot.ppm
Gdot

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

Beta Ganglion Cells in Cat Retina
crossdist.default

Pairwise distances between two different sets of points
cut.ppp

Convert Point Pattern Marks from Numeric to Factor
disc

Circular Window
finpines

Pine saplings in Finland.
hyperframe

Hyper Data Frame
is.ppp

Test Whether An Object Is A Point Pattern
mean.im

Mean Pixel Value in an Image
pppmatching.object

Class of Point Matchings
quad.object

Class of Quadrature Schemes
rpoispp

Generate Poisson Point Pattern
rmhmodel.ppm

Interpret Fitted Model for Metropolis-Hastings Simulation.
runifdisc

Generate N Uniform Random Points in a Disc
summary.listof

Summary of a List of Things
pairwise.family

Pairwise Interaction Process Family
pppmatching

Create a Point Matching
residuals.ppm

Residuals for Fitted Point Process Model
subset.im

Extract Subset of Image