Learn R Programming

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

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

18,534

Version

1.12-3

License

GPL (>= 2)

Maintainer

Adrian Baddeley

Last Published

March 22nd, 2025

Functions in spatstat (1.12-3)

OrdThresh

Ord's Interaction model
Pairwise

Generic Pairwise Interaction model
is.multitype.ppm

Test Whether A Point Process Model is Multitype
is.im

Test Whether An Object Is A Pixel Image
im.object

Class of Images
Gmulti

Marked Nearest Neighbour Distance Function
ord.family

Ord Interaction Process Family
affine.ppp

Apply Affine Transformation To Point Pattern
redwoodfull

California Redwoods Point Pattern (Entire Dataset)
progressreport

Print Progress Reports
Kest.fft

K-function using FFT
bounding.box

Bounding Box of a Window or Point Pattern
Kinhom

Inhomogeneous K-function
eval.fv

Evaluate Expression Involving Functions
data.ppm

Extract Original Data from a Fitted Point Process Model
crossdist

Pairwise distances
Saturated

Saturated Pairwise Interaction model
distmap.ppp

Distance Map of Point Pattern
DiggleGratton

Diggle-Gratton model
rotate.ppp

Rotate a Point Pattern
rsyst

Simulate systematic random point pattern
union.quad

Union of Data and Dummy Points
MultiStrauss

The Multitype Strauss Point Process Model
as.owin

Convert Data To Class owin
ants

Harkness-Isham ants' nests data
vcov.ppm

Variance-Covariance Matrix for a Fitted Point Process Model
Gdot

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

Estimate the empty space function F
is.multitype.ppp

Test Whether A Point Pattern is Multitype
pairdist

Pairwise distances
Jdot

Multitype J Function (i-to-any)
kaplan.meier

Kaplan-Meier Estimator using Histogram Data
pairdist.psp

Pairwise distances between line segments
clickppp

Interactively Add Points
gridcentres

Rectangular grid of points
plot.splitppp

Plot a List of Point Patterns
StraussHard

The Strauss / Hard Core Point Process Model
pcf.ppp

Pair Correlation Function of Point Pattern
Poisson

Poisson Point Process Model
plot.plotppm

Plot a plotppm Object Created by plot.ppm
plot.hyperframe

Plot Entries in a Hyperframe
print.owin

Print Brief Details of a Spatial Window
Gest

Nearest Neighbour Distance Function G
as.matrix.im

Convert Pixel Image to Matrix
chorley

Chorley-Ribble Cancer Data
profilepl

Profile Maximum Pseudolikelihood
dilate.owin

Dilate a Window
bounding.box.xy

Convex Hull of Points
bramblecanes

Hutchings' Bramble Canes data
concatxy

Concatenate x,y Coordinate Vectors
spatstat

The Spatstat Package
envelope

Simulation envelopes of summary function
endpoints.psp

Endpoints of Line Segment Pattern
distmap.owin

Distance Map of Window
distmap.psp

Distance Map of Line Segment Pattern
anova.ppm

ANOVA for Fitted Point Process Models
PairPiece

The Piecewise Constant Pairwise Interaction Point Process Model
bdist.points

Distance to Boundary of Window
density.splitppp

Kernel Smoothed Intensity of Split Point Pattern
Lest

L-function
clarkevans

Clark and Evans Aggregation Index
allstats

Calculate four standard summary functions of a point pattern.
crossdist.psp

Pairwise distances between two different line segment patterns
as.mask

Pixel Image Approximation of a Window
crossdist.default

Pairwise distances between two different sets of points
psp.object

Class of Line Segment Patterns
quad.object

Class of Quadrature Schemes
as.im

Convert to Pixel Image
plot.psp

plot a Spatial Line Segment Pattern
rescale

Convert dataset to another unit of length
ppm

Fit Point Process Model to Data
anemones

Beadlet Anemones Data
rThomas

Simulate Thomas Process
hyperframe

Hyper Data Frame
spatstat-deprecated

Deprecated spatstat functions
rlabel

Random Re-Labelling of Point Pattern
japanesepines

Japanese Pines Point Pattern
rpoispp

Generate Poisson Point Pattern
Geyer

Geyer's Saturation Point Process Model
applynbd

Apply Function to Every Neighbourhood in a Point Pattern
setcov

Set Covariance of a Window
ponderosa

Ponderosa Pine Tree Point Pattern
Kmulti

Marked K-Function
hist.im

Histogram of Pixel Values in an Image
Kdot.inhom

Inhomogeneous Multitype K Dot Function
Softcore

The Soft Core Point Process Model
spokes

Spokes pattern of dummy points
psp

Create a Line Segment Pattern
raster.x

Cartesian Coordinates for a Pixel Raster
inside.owin

Test Whether Points Are Inside A Window
coef.ppm

Coefficients of Fitted Point Process Model
fitin.ppm

Extract the Interaction from a Fitted Point Process Model
markcorr

Mark Correlation Function
print.ppm

Print a Fitted Point Process Model
identify.ppp

Identify Points in a Point Pattern
print.im

Print Brief Details of an Image
multiplicity.ppp

Count Multiplicity of Duplicate Points
rlinegrid

Generate grid of parallel lines with random displacement
rNeymanScott

Simulate Neyman-Scott Process
ks.test.ppm

Kolmogorov-Smirnov Test for Point Process Model
residuals.ppm

Residuals for Fitted Point Process Model
intersect.owin

Intersection or Union of Two Windows
rStrauss

Perfect Simulation of the Strauss Process
nearest.raster.point

Find Pixel Nearest to a Given Point
simdat

Simulated Point Pattern
rescale.psp

Convert Line Segment Pattern to Another Unit of Length
Iest

Estimate the I-function
Kest

K-function
owin

Create a Window
alltypes

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

Summary of a Point Pattern Dataset
convexhull.xy

Convex Hull of Points
diameter

Diameter of a Window
append.psp

Combine Two Line Segment Patterns
is.marked

Test Whether Marks Are Present
nnwhich

Nearest neighbour
Ord

Generic Ord Interaction model
betacells

Beta Ganglion Cells in Cat Retina
pcf.fv

Pair Correlation Function obtained from K Function
crossdist.ppp

Pairwise distances between two different point patterns
affine.owin

Apply Affine Transformation To Window
pppmatching.object

Class of Point Matchings
amacrine

Hughes' Amacrine Cell Data
clickpoly

Interactively Define a Polygon
shift

Apply Vector Translation
lurking

Lurking variable plot
selfcrossing.psp

Crossing Points in a Line Segment Pattern
density.ppp

Kernel Smoothed Intensity of Point Pattern
ppp.object

Class of Point Patterns
plot.listof

Plot a List of Things
centroid.owin

Centroid of a window
eval.hyper

Evaluate an Expression in Each Row of a Hyperframe
qqplot.ppm

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

Print Brief Details of a Line Segment Pattern Dataset
smooth.ppp

Spatial smoothing of observations at irregular points
trim.rectangle

Cut margins from rectangle
vertices

Vertices of a Window
rmhmodel.list

Define Point Process Model for Metropolis-Hastings Simulation.
is.ppp

Test Whether An Object Is A Point Pattern
rSSI

Simulate Simple Sequential Inhibition
rmpoispp

Generate Multitype Poisson Point Pattern
default.dummy

Generate a Default Pattern of Dummy Points
discretise

Safely Convert Point Pattern Window to Binary Mask
rmh.ppm

Simulate from a Fitted Point Process Model
square

Square Window
subset.ppp

Extract or Replace Subset of Point Pattern
ppp

Create a Point Pattern
nndist.psp

Nearest neighbour distances between line segments
superimpose

Superimpose Several Point Patterns
rescue.rectangle

Convert Window Back To Rectangle
rmhstart

Determine Initial State for Metropolis-Hastings Simulation.
summary.ppm

Summarizing a Fitted Point Process Model
solutionset

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

Aherne's hamster tumour data
rmhmodel

Define Point Process Model for Metropolis-Hastings Simulation.
unmark

Remove Marks from a Marked Point Pattern
plot.quad

plot a Spatial Quadrature Scheme
humberside

Humberside Data on Childhood Leukaemia and Lymphoma
nncross

Nearest Neighbour in Another Point Pattern
Strauss

The Strauss Point Process Model
pcf.fasp

Pair Correlation Function obtained from array of K functions
quad.ppm

Extract Quadrature Scheme Used to Fit a Point Process Model
im

Create a Pixel Image Object
reduced.sample

Reduced Sample Estimator using Histogram Data
Kcross.inhom

Inhomogeneous Cross K Function
duplicated.ppp

Determine Duplicated Points in a Spatial Point Pattern
is.subset.owin

Determine Whether One Window is Contained In Another
levelset

Level Set of a Pixel Image
harmonic

Basis for Harmonic Functions
subset.im

Extract Subset of Image
runifpoint

Generate N Uniform Random Points
rstrat

Simulate Stratified Random Point Pattern
subsetget.im

Reset Values in Subset of Image
rescale.ppp

Convert Point Pattern to Another Unit of Length
residualspaper

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

Midpoints of Line Segment Pattern
shift.owin

Apply Vector Translation To Window
compatible.im

Test Whether Two Pixel Images Are Compatible
as.psp

Convert Data To Class psp
as.ppp

Convert Data To Class ppp
nbfires

Point Patterns of New Brunswick Forest Fires
mincontrast

Method of Minimum Contrast
km.rs

Kaplan-Meier and Reduced Sample Estimator using Histograms
rshift.splitppp

Randomly Shift a List of Point Patterns
shift.psp

Apply Vector Translation To Line Segment Pattern
disc

Circular Window
LennardJones

The Lennard-Jones Potential
MultiStraussHard

The Multitype/Hard Core Strauss Point Process Model
persp.im

Perspective Plot of Pixel Image
area.owin

Area of a Window
as.data.frame.ppp

Coerce Point Pattern to a Data Frame
subset.fv

Extract Subset of Function Values
subset.listof

Extract or Replace Subset of a List of Things
lgcp.estK

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

Distance for a Point Pattern Matching
contour.im

Contour plot of pixel image
affine

Apply Affine Transformation
compatible.fv

Test Whether Two Function Objects Are Compatible
eval.im

Evaluate Expression Involving Pixel Images
summary.im

Summarizing a Pixel Image
rshift.ppp

Randomly Shift a Point Pattern
cut.ppp

Convert Point Pattern Marks from Numeric to Factor
runifdisc

Generate N Uniform Random Points in a Disc
logLik.ppm

Log Likelihood for Poisson Point Process Model
fitted.ppm

Fitted Conditional Intensity for Point Process Model
subset.psp

Extract Subset of Line Segment Pattern
summary.quad

Summarizing a Quadrature Scheme
eroded.areas

Areas of Morphological Erosions
markstat

Summarise Marks in Every Neighbourhood in a Point Pattern
pairsat.family

Saturated Pairwise Interaction Point Process Family
dummy.ppm

Extract Dummy Points Used to Fit a Point Process Model
nncorr

Nearest-Neighbour Correlation of Marked Point Pattern
Kdot

Multitype K Function (i-to-any)
plot.im

Plot a Pixel Image
copper

Berman-Huntington points and lines data
owin.object

Class owin
matclust.estK

Fit the Matern Cluster Point Process by Minimum Contrast
pcf

Pair Correlation Function
demopat

Artificial Data Point Pattern
plot.ppm

plot a Fitted Point Process Model
letterR

Window in Shape of Letter R
plot.ppp

plot a Spatial Point Pattern
plot.owin

Plot a Spatial Window
is.marked.ppp

Test Whether A Point Pattern is Marked
interp.im

Interpolate a Pixel Image
erode.owin

Erode a Window
pppdist

Distance Between Two Point Patterns
pairdist.ppp

Pairwise distances
ewcdf

Weighted Empirical Cumulative Distribution Function
ppm.object

Class of Fitted Point Process Models
plot.fv

Plot Function Valuesn
rmhmodel.ppm

Interpret Fitted Model for Metropolis-Hastings Simulation.
quadratcount

Quadrat counting for a point pattern
rmhcontrol

Set Control Parameters for Metropolis-Hastings Algorithm.
localK

Neighbourhood density function
rotate

Rotate
rescale.owin

Convert Window to Another Unit of Length
is.owin

Test Whether An Object Is A Window
cells

Biological Cells Point Pattern
reach

Interaction Distance of a Point Process
cut.im

Convert Pixel Image from Numeric to Factor
rthin

Random Thinning
density.psp

Kernel Smoothing of Line Segment Pattern
rpoint

Generate N Random Points
shift.im

Apply Vector Translation To Pixel Image
rshift.psp

Randomly Shift a Line Segment Pattern
thomas.estK

Fit the Thomas Point Process by Minimum Contrast
update.ppm

Update a Fitted Point Process Model
dirichlet.weights

Compute Quadrature Weights Based on Dirichlet Tessellation
ripras

Estimate window from points alone
nndist

Nearest neighbour distances
setmarks

Set or Reset the Marks in a Point Pattern
scanpp

Read Point Pattern From Data File
summary.listof

Summary of a List of Things
fasp.object

Function Arrays for Spatial Patterns
suffstat

Sufficient Statistic of Point Process Model
summary.splitppp

Summary of a Split Point Pattern
predict.ppm

Prediction from a Fitted Point Process Model
unique.ppp

Extract Unique Points from a Spatial Point Pattern
fv.object

Data Frames of Function Values
rMaternI

Simulate Matern Model I
spruces

Spruces Point Pattern
rotate.psp

Rotate a Line Segment Pattern
rotate.owin

Rotate a Window
complement.owin

Take Complement of a Window
corners

Corners of a rectangle
plot.fasp

Plot a Function Array
pppmatching

Create a Point Matching
crossing.psp

Crossing Points of Two Line Segment Patterns
is.marked.ppm

Test Whether A Point Process Model is Marked
split.ppp

Divide Point Pattern into Sub-patterns
longleaf

Longleaf Pines Point Pattern
rmh.default

Simulate Point Process Models using the Metropolis-Hastings Algorithm.
rmhmodel.default

Build Point Process Model for Metropolis-Hastings Simulation.
rshift

Random Shift
rcell

Simulate Baddeley-Silverman Cell Process
shift.ppp

Apply Vector Translation To Point Pattern
subset.splitppp

Extract or Replace Sub-Patterns
rmh

Simulate point patterns using the Metropolis-Hastings algorithm.
bdist.pixels

Distance to Boundary of Window
Kmeasure

Reduced Second Moment Measure
finpines

Pine saplings in Finland.
mean.im

Mean Pixel Value in an Image
pairwise.family

Pairwise Interaction Process Family
print.quad

Print a Quadrature Scheme
quadrat.test

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

California Redwoods Point Pattern (Ripley's Subset)
quadscheme

Generate a Quadrature Scheme from a Point Pattern
Gcross

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

Multitype K Function (Cross-type)
angles.psp

Orientation Angles of Line Segments
ganglia

Beta Ganglion Cells in Cat Retina, Old Version
affine.psp

Apply Affine Transformation To Line Segment Pattern
gridweights

Compute Quadrature Weights Based on Grid Counts
spatstat-internal

Internal spatstat functions
eem

Exponential Energy Marks
is.multitype

Test whether Object is Multitype
expand.owin

Expand Window By Factor
is.ppm

Test Whether An Object Is A Fitted Point Process Model
lansing

Lansing Woods Point Pattern
pairdist.default

Pairwise distances
print.ppp

Print Brief Details of a Point Pattern Dataset
quantile.im

Sample Quantiles of Pixel Image
rmpoint

Generate N Random Multitype Points
spatstat.options

Internal Options in Spatstat Package
summary.owin

Summary of a Spatial Window
unitname

Name for Unit of Length
summary.psp

Summary of a Line Segment Pattern Dataset
Jest

Estimate the J-function
Jmulti

Marked J Function
Jcross

Multitype J Function (i-to-j)
as.rectangle

Window Frame
bei

Tropical rain forest trees
diagnose.ppm

Diagnostic Plots for Fitted Point Process Model
distmap

Distance Map
lengths.psp

Lengths of Line Segments
nztrees

New Zealand Trees Point Pattern
rMatClust

Simulate Matern Cluster Process
rMaternII

Simulate Matern Model II
rpoisline

Generate Poisson Random Line Process
subset.fasp

Extract Subset of Function Array
swedishpines

Swedish Pines Point Pattern