Learn R Programming

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

spatstat (version 1.12-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

16,590

Version

1.12-2

License

GPL version 2 or newer

Maintainer

Adrian Baddeley

Last Published

March 22nd, 2025

Functions in spatstat (1.12-2)

Geyer

Geyer's Saturation Point Process Model
as.ppp

Convert Data To Class ppp
cut.ppp

Convert Point Pattern Marks from Numeric to Factor
ks.test.ppm

Kolmogorov-Smirnov Test for Point Process Model
midpoints.psp

Midpoints of Line Segment Pattern
plot.hyperframe

Plot Entries in a Hyperframe
plot.fasp

Plot a Function Array
rshift

Random Shift
rmpoint

Generate N Random Multitype Points
shift.ppp

Apply Vector Translation To Point Pattern
affine.ppp

Apply Affine Transformation To Point Pattern
corners

Corners of a rectangle
clickppp

Interactively Add Points
smooth.ppp

Spatial smoothing of observations at irregular points
demopat

Artificial Data Point Pattern
Fest

Estimate the empty space function F
as.data.frame.ppp

Coerce Point Pattern to a Data Frame
as.owin

Convert Data To Class owin
spruces

Spruces Point Pattern
update.ppm

Update a Fitted Point Process Model
bounding.box

Bounding Box of a Window or Point Pattern
bdist.points

Distance to Boundary of Window
Kest

K-function
affine.psp

Apply Affine Transformation To Line Segment Pattern
clickpoly

Interactively Define a Polygon
crossing.psp

Crossing Points of Two Line Segment Patterns
im

Create a Pixel Image Object
contour.im

Contour plot of pixel image
eroded.areas

Areas of Morphological Erosions
mean.im

Mean Pixel Value in an Image
envelope

Simulation envelopes of summary function
pairdist

Pairwise distances
hamster

Aherne's hamster tumour data
is.multitype.ppp

Test Whether A Point Pattern is Multitype
Kdot

Multitype K Function (i-to-any)
MultiStraussHard

The Multitype/Hard Core Strauss Point Process Model
pairdist.psp

Pairwise distances between line segments
plot.owin

Plot a Spatial Window
matclust.estK

Fit the Matern Cluster Point Process by Minimum Contrast
dummy.ppm

Extract Dummy Points Used to Fit a Point Process Model
multiplicity.ppp

Count Multiplicity of Duplicate Points
print.im

Print Brief Details of an Image
plot.ppp

plot a Spatial Point Pattern
density.psp

Kernel Smoothing of Line Segment Pattern
spatstat-deprecated

Deprecated spatstat functions
Jcross

Multitype J Function (i-to-j)
Jdot

Multitype J Function (i-to-any)
gridweights

Compute Quadrature Weights Based on Grid Counts
plot.plotppm

Plot a plotppm Object Created by plot.ppm
eval.hyper

Evaluate an Expression in Each Row of a Hyperframe
angles.psp

Orientation Angles of Line Segments
as.matrix.im

Convert Pixel Image to Matrix
pairsat.family

Saturated Pairwise Interaction Point Process Family
fitin.ppm

Extract the Interaction from a Fitted Point Process Model
eval.fv

Evaluate Expression Involving Functions
diameter

Diameter of a Window
discretise

Safely Convert Point Pattern Window to Binary Mask
alltypes

Calculate Statistic for All Types in a Multitype Point Pattern
plot.splitppp

Plot a List of Point Patterns
quad.object

Class of Quadrature Schemes
eem

Exponential Energy Marks
superimpose

Superimpose Several Point Patterns
subset.im

Extract Subset of Image
as.psp

Convert Data To Class psp
is.marked.ppm

Test Whether A Point Process Model is Marked
gridcentres

Rectangular grid of points
localK

Neighbourhood density function
anemones

Beadlet Anemones Data
allstats

Calculate four standard summary functions of a point pattern.
ripras

Estimate window from points alone
pcf.fasp

Pair Correlation Function obtained from array of K functions
print.ppp

Print Brief Details of a Point Pattern Dataset
rotate.owin

Rotate a Window
fv.object

Data Frames of Function Values
rshift.psp

Randomly Shift a Line Segment Pattern
rthin

Random Thinning
rSSI

Simulate Simple Sequential Inhibition
quantile.im

Sample Quantiles of Pixel Image
harmonic

Basis for Harmonic Functions
Ord

Generic Ord Interaction model
redwood

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

Convert Point Pattern to Another Unit of Length
shift.im

Apply Vector Translation To Pixel Image
Kmulti

Marked K-Function
Gcross

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

Reduced Second Moment Measure
compatible.fv

Test Whether Two Function Objects Are Compatible
humberside

Humberside Data on Childhood Leukaemia and Lymphoma
as.im

Convert to Pixel Image
Kdot.inhom

Inhomogeneous Multitype K Dot Function
bramblecanes

Hutchings' Bramble Canes data
clarkevans

Clark and Evans Aggregation Index
letterR

Window in Shape of Letter R
pairwise.family

Pairwise Interaction Process Family
im.object

Class of Images
as.rectangle

Window Frame
rmhmodel

Define Point Process Model for Metropolis-Hastings Simulation.
crossdist

Pairwise distances
complement.owin

Take Complement of a Window
nbfires

Point Patterns of New Brunswick Forest Fires
distmap

Distance Map
Gdot

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

Estimate the J-function
nncorr

Nearest-Neighbour Correlation of Marked Point Pattern
bounding.box.xy

Convex Hull of Points
owin

Create a Window
MultiStrauss

The Multitype Strauss Point Process Model
erode.owin

Erode a Window
plot.listof

Plot a List of Things
profilepl

Profile Maximum Pseudolikelihood
fasp.object

Function Arrays for Spatial Patterns
ants

Harkness-Isham ants' nests data
cut.im

Convert Pixel Image from Numeric to Factor
inside.owin

Test Whether Points Are Inside A Window
setcov

Set Covariance of a Window
subset.ppp

Extract or Replace Subset of Point Pattern
Kcross.inhom

Inhomogeneous Cross K Function
suffstat

Sufficient Statistic of Point Process Model
hist.im

Histogram of Pixel Values in an Image
subsetget.im

Reset Values in Subset of Image
nndist.psp

Nearest neighbour distances between line segments
rmh.default

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

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

Remove Marks from a Marked Point Pattern
owin.object

Class owin
Kinhom

Inhomogeneous K-function
expand.owin

Expand Window By Factor
Strauss

The Strauss Point Process Model
subset.splitppp

Extract or Replace Sub-Patterns
vertices

Vertices of a Window
copper

Berman-Huntington points and lines data
Jmulti

Marked J Function
identify.ppp

Identify Points in a Point Pattern
simdat

Simulated Point Pattern
dilate.owin

Dilate a Window
endpoints.psp

Endpoints of Line Segment Pattern
amacrine

Hughes' Amacrine Cell Data
markstat

Summarise Marks in Every Neighbourhood in a Point Pattern
ewcdf

Weighted Empirical Cumulative Distribution Function
DiggleGratton

Diggle-Gratton model
spatstat

The Spatstat Package
summary.ppp

Summary of a Point Pattern Dataset
japanesepines

Japanese Pines Point Pattern
Iest

Estimate the I-function
interp.im

Interpolate a Pixel Image
ganglia

Beta Ganglion Cells in Cat Retina, Old Version
lansing

Lansing Woods Point Pattern
OrdThresh

Ord's Interaction model
data.ppm

Extract Original Data from a Fitted Point Process Model
concatxy

Concatenate x,y Coordinate Vectors
nnwhich

Nearest neighbour
hyperframe

Hyper Data Frame
subset.psp

Extract Subset of Line Segment Pattern
ppp

Create a Point Pattern
spatstat-internal

Internal spatstat functions
summary.listof

Summary of a List of Things
ord.family

Ord Interaction Process Family
summary.psp

Summary of a Line Segment Pattern Dataset
psp

Create a Line Segment Pattern
pcf

Pair Correlation Function
ppp.object

Class of Point Patterns
pcf.fv

Pair Correlation Function obtained from K Function
StraussHard

The Strauss / Hard Core Point Process Model
pppdist

Distance Between Two Point Patterns
rThomas

Simulate Thomas Process
append.psp

Combine Two Line Segment Patterns
print.quad

Print a Quadrature Scheme
crossdist.default

Pairwise distances between two different sets of points
redwoodfull

California Redwoods Point Pattern (Entire Dataset)
vcov.ppm

Variance-Covariance Matrix for a Fitted Point Process Model
is.im

Test Whether An Object Is A Pixel Image
fitted.ppm

Fitted Conditional Intensity for Point Process Model
is.multitype

Test whether Object is Multitype
predict.ppm

Prediction from a Fitted Point Process Model
kaplan.meier

Kaplan-Meier Estimator using Histogram Data
levelset

Level Set of a Pixel Image
is.subset.owin

Determine Whether One Window is Contained In Another
swedishpines

Swedish Pines Point Pattern
matchingdist

Distance for a Point Pattern Matching
mincontrast

Method of Minimum Contrast
nndist

Nearest neighbour distances
pcf.ppp

Pair Correlation Function of Point Pattern
logLik.ppm

Log Likelihood for Poisson Point Process Model
rNeymanScott

Simulate Neyman-Scott Process
rMaternII

Simulate Matern Model II
nztrees

New Zealand Trees Point Pattern
plot.quad

plot a Spatial Quadrature Scheme
nearest.raster.point

Find Pixel Nearest to a Given Point
ponderosa

Ponderosa Pine Tree Point Pattern
plot.im

Plot a Pixel Image
affine

Apply Affine Transformation
residuals.ppm

Residuals for Fitted Point Process Model
rstrat

Simulate Stratified Random Point Pattern
rStrauss

Perfect Simulation of the Strauss Process
rmhmodel.default

Build Point Process Model for Metropolis-Hastings Simulation.
setmarks

Set or Reset the Marks in a Point Pattern
chorley

Chorley-Ribble Cancer Data
reduced.sample

Reduced Sample Estimator using Histogram Data
convexhull.xy

Convex Hull of Points
runifdisc

Generate N Uniform Random Points in a Disc
summary.im

Summarizing a Pixel Image
subset.fasp

Extract Subset of Function Array
is.marked

Test Whether Marks Are Present
rescale.owin

Convert Window to Another Unit of Length
thomas.estK

Fit the Thomas Point Process by Minimum Contrast
reach

Interaction Distance of a Point Process
quadratcount

Quadrat counting for a point pattern
quad.ppm

Extract Quadrature Scheme Used to Fit a Point Process Model
print.owin

Print Brief Details of a Spatial Window
print.psp

Print Brief Details of a Line Segment Pattern Dataset
Softcore

The Soft Core Point Process Model
duplicated.ppp

Determine Duplicated Points in a Spatial Point Pattern
print.ppm

Print a Fitted Point Process Model
rcell

Simulate Baddeley-Silverman Cell Process
quadscheme

Generate a Quadrature Scheme from a Point Pattern
rmhmodel.ppm

Interpret Fitted Model for Metropolis-Hastings Simulation.
distmap.ppp

Distance Map of Point Pattern
km.rs

Kaplan-Meier and Reduced Sample Estimator using Histograms
rmh

Simulate point patterns using the Metropolis-Hastings algorithm.
trim.rectangle

Cut margins from rectangle
rmhstart

Determine Initial State for Metropolis-Hastings Simulation.
rescue.rectangle

Convert Window Back To Rectangle
rpoispp

Generate Poisson Point Pattern
subset.listof

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

Pairwise distances
pairdist.default

Pairwise distances
rmpoispp

Generate Multitype Poisson Point Pattern
rlinegrid

Generate grid of parallel lines with random displacement
rsyst

Simulate systematic random point pattern
shift.psp

Apply Vector Translation To Line Segment Pattern
rpoint

Generate N Random Points
rotate.ppp

Rotate a Point Pattern
plot.psp

plot a Spatial Line Segment Pattern
qqplot.ppm

Q-Q Plot of Residuals from Fitted Point Process Model
union.quad

Union of Data and Dummy Points
rMatClust

Simulate Matern Cluster Process
unique.ppp

Extract Unique Points from a Spatial Point Pattern
raster.x

Cartesian Coordinates for a Pixel Raster
rlabel

Random Re-Labelling of Point Pattern
centroid.owin

Centroid of a window
bdist.pixels

Distance to Boundary of Window
crossdist.psp

Pairwise distances between two different line segment patterns
shift

Apply Vector Translation
summary.splitppp

Summary of a Split Point Pattern
density.ppp

Kernel Smoothed Intensity of Point Pattern
eval.im

Evaluate Expression Involving Pixel Images
is.ppm

Test Whether An Object Is A Fitted Point Process Model
markcorr

Mark Correlation Function
ppm

Fit Point Process Model to Data
pppmatching.object

Class of Point Matchings
rmhmodel.list

Define Point Process Model for Metropolis-Hastings Simulation.
rpoisline

Generate Poisson Random Line Process
split.ppp

Divide Point Pattern into Sub-patterns
spatstat.options

Internal Options in Spatstat Package
Gest

Nearest Neighbour Distance Function G
LennardJones

The Lennard-Jones Potential
PairPiece

The Piecewise Constant Pairwise Interaction Point Process Model
Saturated

Saturated Pairwise Interaction model
affine.owin

Apply Affine Transformation To Window
crossdist.ppp

Pairwise distances between two different point patterns
default.dummy

Generate a Default Pattern of Dummy Points
density.splitppp

Kernel Smoothed Intensity of Split Point Pattern
distmap.psp

Distance Map of Line Segment Pattern
progressreport

Print Progress Reports
quadrat.test

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

Data and Code From JRSS Discussion Paper on Residuals
rmh.ppm

Simulate from a Fitted Point Process Model
rshift.splitppp

Randomly Shift a List of Point Patterns
runifpoint

Generate N Uniform Random Points
subset.fv

Extract Subset of Function Values
summary.owin

Summary of a Spatial Window
area.owin

Area of a Window
bei

Tropical rain forest trees
disc

Circular Window
is.multitype.ppm

Test Whether A Point Process Model is Multitype
is.ppp

Test Whether An Object Is A Point Pattern
persp.im

Perspective Plot of Pixel Image
lgcp.estK

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

Convert Line Segment Pattern to Another Unit of Length
rescale

Convert dataset to another unit of length
shift.owin

Apply Vector Translation To Window
rotate.psp

Rotate a Line Segment Pattern
square

Square Window
summary.quad

Summarizing a Quadrature Scheme
Lest

L-function
as.mask

Pixel Image Approximation of a Window
Pairwise

Generic Pairwise Interaction model
cells

Biological Cells Point Pattern
compatible.im

Test Whether Two Pixel Images Are Compatible
diagnose.ppm

Diagnostic Plots for Fitted Point Process Model
dirichlet.weights

Compute Quadrature Weights Based on Dirichlet Tessellation
finpines

Pine saplings in Finland.
is.marked.ppp

Test Whether A Point Pattern is Marked
lurking

Lurking variable plot
rmhcontrol

Set Control Parameters for Metropolis-Hastings Algorithm.
ppm.object

Class of Fitted Point Process Models
rotate

Rotate
summary.ppm

Summarizing a Fitted Point Process Model
unitname

Name for Unit of Length
Gmulti

Marked Nearest Neighbour Distance Function
Kest.fft

K-function using FFT
betacells

Beta Ganglion Cells in Cat Retina
Poisson

Poisson Point Process Model
coef.ppm

Coefficients of Fitted Point Process Model
distmap.owin

Distance Map of Window
nncross

Nearest Neighbour in Another Point Pattern
longleaf

Longleaf Pines Point Pattern
plot.ppm

plot a Fitted Point Process Model
rMaternI

Simulate Matern Model I
spokes

Spokes pattern of dummy points
Kcross

Multitype K Function (Cross-type)
anova.ppm

ANOVA for Fitted Point Process Models
applynbd

Apply Function to Every Neighbourhood in a Point Pattern
intersect.owin

Intersection or Union of Two Windows
is.owin

Test Whether An Object Is A Window
pppmatching

Create a Point Matching
plot.fv

Plot Function Valuesn
lengths.psp

Lengths of Line Segments
psp.object

Class of Line Segment Patterns
rshift.ppp

Randomly Shift a Point Pattern
selfcrossing.psp

Crossing Points in a Line Segment Pattern
scanpp

Read Point Pattern From Data File