Learn R Programming

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

spatstat (version 1.12-5)

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,015

Version

1.12-5

License

GPL (>= 2)

Maintainer

Adrian Baddeley

Last Published

March 22nd, 2025

Functions in spatstat (1.12-5)

Kest

K-function
DiggleGratton

Diggle-Gratton model
Ord

Generic Ord Interaction model
anemones

Beadlet Anemones Data
Geyer

Geyer's Saturation Point Process Model
Gest

Nearest Neighbour Distance Function G
spatstat

The Spatstat Package
Jdot

Multitype J Function (i-to-any)
MultiStrauss

The Multitype Strauss Point Process Model
bei

Tropical rain forest trees
Kinhom

Inhomogeneous K-function
Softcore

The Soft Core Point Process Model
chorley

Chorley-Ribble Cancer Data
Jest

Estimate the J-function
Strauss

The Strauss Point Process Model
bdist.points

Distance to Boundary of Window
Saturated

Saturated Pairwise Interaction model
applynbd

Apply Function to Every Neighbourhood in a Point Pattern
as.matrix.im

Convert Pixel Image to Matrix
Kest.fft

K-function using FFT
cut.ppp

Convert Point Pattern Marks from Numeric to Factor
corners

Corners of a rectangle
as.rectangle

Window Frame
contour.im

Contour plot of pixel image
StraussHard

The Strauss / Hard Core Point Process Model
as.owin

Convert Data To Class owin
bounding.box.xy

Convex Hull of Points
eval.im

Evaluate Expression Involving Pixel Images
Kdot

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

Area of a Window
affine.owin

Apply Affine Transformation To Window
Gcross

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

Multitype Nearest Neighbour Distance Function (i-to-any)
centroid.owin

Centroid of a window
PairPiece

The Piecewise Constant Pairwise Interaction Point Process Model
duplicated.ppp

Determine Duplicated Points in a Spatial Point Pattern
Jcross

Multitype J Function (i-to-j)
im.object

Class of Images
LennardJones

The Lennard-Jones Potential
fasp.object

Function Arrays for Spatial Patterns
distmap

Distance Map
as.ppp

Convert Data To Class ppp
as.psp

Convert Data To Class psp
compatible.im

Test Whether Two Pixel Images Are Compatible
hist.im

Histogram of Pixel Values in an Image
convexhull.xy

Convex Hull of Points
bounding.box

Bounding Box of a Window or Point Pattern
endpoints.psp

Endpoints of Line Segment Pattern
Kcross.inhom

Inhomogeneous Cross K Function
midpoints.psp

Midpoints of Line Segment Pattern
affine.psp

Apply Affine Transformation To Line Segment Pattern
dummy.ppm

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

Pairwise distances between two different point patterns
dilate.owin

Dilate a Window
Gmulti

Marked Nearest Neighbour Distance Function
levelset

Level Set of a Pixel Image
ewcdf

Weighted Empirical Cumulative Distribution Function
is.marked.ppm

Test Whether A Point Process Model is Marked
betacells

Beta Ganglion Cells in Cat Retina
ppp.object

Class of Point Patterns
eroded.areas

Areas of Morphological Erosions
concatxy

Concatenate x,y Coordinate Vectors
plot.fv

Plot Function Valuesn
OrdThresh

Ord's Interaction model
as.im

Convert to Pixel Image
cut.im

Convert Pixel Image from Numeric to Factor
cells

Biological Cells Point Pattern
clickppp

Interactively Add Points
ants

Harkness-Isham ants' nests data
lansing

Lansing Woods Point Pattern
is.multitype.ppm

Test Whether A Point Process Model is Multitype
anova.ppm

ANOVA for Fitted Point Process Models
Kdot.inhom

Inhomogeneous Multitype K Dot Function
pcf

Pair Correlation Function
disc

Circular Window
Pairwise

Generic Pairwise Interaction model
rescale

Convert dataset to another unit of length
distmap.psp

Distance Map of Line Segment Pattern
Kmeasure

Reduced Second Moment Measure
discretise

Safely Convert Point Pattern Window to Binary Mask
eval.hyper

Evaluate an Expression in Each Row of a Hyperframe
rsyst

Simulate systematic random point pattern
append.psp

Combine Two Line Segment Patterns
Jmulti

Marked J Function
demopat

Artificial Data Point Pattern
bramblecanes

Hutchings' Bramble Canes data
alltypes

Calculate Statistic for All Types in a Multitype Point Pattern
finpines

Pine saplings in Finland.
MultiStraussHard

The Multitype/Hard Core Strauss Point Process Model
as.data.frame.ppp

Coerce Point Pattern to a Data Frame
amacrine

Hughes' Amacrine Cell Data
as.mask

Pixel Image Approximation of a Window
compatible.fv

Test Whether Two Function Objects Are Compatible
clickpoly

Interactively Define a Polygon
Poisson

Poisson Point Process Model
intersect.owin

Intersection or Union of Two Windows
im

Create a Pixel Image Object
complement.owin

Take Complement of a Window
clarkevans

Clark and Evans Aggregation Index
Kmulti

Marked K-Function
Kcross

Multitype K Function (Cross-type)
crossdist.default

Pairwise distances between two different sets of points
bdist.pixels

Distance to Boundary of Window
logLik.ppm

Log Likelihood for Poisson Point Process Model
copper

Berman-Huntington points and lines data
is.multitype.ppp

Test Whether A Point Pattern is Multitype
harmonic

Basis for Harmonic Functions
diagnose.ppm

Diagnostic Plots for Fitted Point Process Model
distmap.ppp

Distance Map of Point Pattern
expand.owin

Expand Window By Factor
humberside

Humberside Data on Childhood Leukaemia and Lymphoma
fv.object

Data Frames of Function Values
ponderosa

Ponderosa Pine Tree Point Pattern
rmhmodel.ppm

Interpret Fitted Model for Metropolis-Hastings Simulation.
lengths.psp

Lengths of Line Segments
plot.listof

Plot a List of Things
pairdist.psp

Pairwise distances between line segments
rmhmodel.list

Define Point Process Model for Metropolis-Hastings Simulation.
km.rs

Kaplan-Meier and Reduced Sample Estimator using Histograms
gridweights

Compute Quadrature Weights Based on Grid Counts
fitted.ppm

Fitted Conditional Intensity for Point Process Model
plot.im

Plot a Pixel Image
rMaternI

Simulate Matern Model I
japanesepines

Japanese Pines Point Pattern
pairsat.family

Saturated Pairwise Interaction Point Process Family
plot.quad

plot a Spatial Quadrature Scheme
is.multitype

Test whether Object is Multitype
rescale.psp

Convert Line Segment Pattern to Another Unit of Length
plot.ppm

plot a Fitted Point Process Model
density.psp

Kernel Smoothing of Line Segment Pattern
plot.splitppp

Plot a List of Point Patterns
owin

Create a Window
summary.listof

Summary of a List of Things
shift.psp

Apply Vector Translation To Line Segment Pattern
qqplot.ppm

Q-Q Plot of Residuals from Fitted Point Process Model
nnwhich

Nearest neighbour
gridcentres

Rectangular grid of points
rThomas

Simulate Thomas Process
distmap.owin

Distance Map of Window
plot.ppp

plot a Spatial Point Pattern
plot.fasp

Plot a Function Array
density.ppp

Kernel Smoothed Intensity of Point Pattern
letterR

Window in Shape of Letter R
rmh

Simulate point patterns using the Metropolis-Hastings algorithm.
suffstat

Sufficient Statistic of Point Process Model
psp

Create a Line Segment Pattern
diameter

Diameter of a Window
summary.ppm

Summarizing a Fitted Point Process Model
rmhmodel

Define Point Process Model for Metropolis-Hastings Simulation.
setcov

Set Covariance of a Window
rshift

Random Shift
runifpoint

Generate N Uniform Random Points
pcf.fv

Pair Correlation Function obtained from K Function
rotate

Rotate
lurking

Lurking variable plot
dirichlet.weights

Compute Quadrature Weights Based on Dirichlet Tessellation
quad.ppm

Extract Quadrature Scheme Used to Fit a Point Process Model
nndist.psp

Nearest neighbour distances between line segments
pcf.fasp

Pair Correlation Function obtained from array of K functions
pppdist

Distance Between Two Point Patterns
crossing.psp

Crossing Points of Two Line Segment Patterns
erode.owin

Erode a Window
identify.ppp

Identify Points in a Point Pattern
rlinegrid

Generate grid of parallel lines with random displacement
ganglia

Beta Ganglion Cells in Cat Retina, Old Version
print.ppm

Print a Fitted Point Process Model
is.im

Test Whether An Object Is A Pixel Image
psp.object

Class of Line Segment Patterns
spokes

Spokes pattern of dummy points
data.ppm

Extract Original Data from a Fitted Point Process Model
default.dummy

Generate a Default Pattern of Dummy Points
interp.im

Interpolate a Pixel Image
is.marked.ppp

Test Whether A Point Pattern is Marked
crossdist

Pairwise distances
hamster

Aherne's hamster tumour data
spatstat-deprecated

Deprecated spatstat functions
redwood

California Redwoods Point Pattern (Ripley's Subset)
eval.fv

Evaluate Expression Involving Functions
ppm.object

Class of Fitted Point Process Models
print.ppp

Print Brief Details of a Point Pattern Dataset
predict.ppm

Prediction from a Fitted Point Process Model
rmpoispp

Generate Multitype Poisson Point Pattern
hyperframe

Hyper Data Frame
rshift.ppp

Randomly Shift a Point Pattern
is.owin

Test Whether An Object Is A Window
is.marked

Test Whether Marks Are Present
is.ppp

Test Whether An Object Is A Point Pattern
is.subset.owin

Determine Whether One Window is Contained In Another
raster.x

Cartesian Coordinates for a Pixel Raster
kstest.ppm

Kolmogorov-Smirnov Test for Point Process Model
owin.object

Class owin
mean.im

Mean Pixel Value in an Image
lgcp.estK

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

Random Thinning
ppm

Fit Point Process Model to Data
eem

Exponential Energy Marks
spruces

Spruces Point Pattern
print.im

Print Brief Details of an Image
smooth.ppp

Spatial smoothing of observations at irregular points
reach

Interaction Distance of a Point Process
ord.family

Ord Interaction Process Family
setmarks

Set or Reset the Marks in a Point Pattern
fitin.ppm

Extract the Interaction from a Fitted Point Process Model
rStrauss

Perfect Simulation of the Strauss Process
residuals.ppm

Residuals for Fitted Point Process Model
pairdist.default

Pairwise distances
persp.im

Perspective Plot of Pixel Image
rcell

Simulate Baddeley-Silverman Cell Process
rmh.ppm

Simulate from a Fitted Point Process Model
matchingdist

Distance for a Point Pattern Matching
rstrat

Simulate Stratified Random Point Pattern
split.ppp

Divide Point Pattern into Sub-patterns
markcorr

Mark Correlation Function
matclust.estK

Fit the Matern Cluster Point Process by Minimum Contrast
subset.ppp

Extract or Replace Subset of Point Pattern
crossdist.psp

Pairwise distances between two different line segment patterns
rmpoint

Generate N Random Multitype Points
rmhmodel.default

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

Plot a Spatial Window
pppmatching

Create a Point Matching
Lest

L-function
shift.im

Apply Vector Translation To Pixel Image
affine

Apply Affine Transformation
Fest

Estimate the empty space function F
rescue.rectangle

Convert Window Back To Rectangle
runifdisc

Generate N Uniform Random Points in a Disc
allstats

Calculate four standard summary functions of a point pattern.
shift.ppp

Apply Vector Translation To Point Pattern
subset.splitppp

Extract or Replace Sub-Patterns
profilepl

Profile Maximum Pseudolikelihood
shift.owin

Apply Vector Translation To Window
quadscheme

Generate a Quadrature Scheme from a Point Pattern
rescale.owin

Convert Window to Another Unit of Length
nncorr

Nearest-Neighbour Correlation of Marked Point Pattern
subset.fv

Extract Subset of Function Values
quadratcount

Quadrat counting for a point pattern
simdat

Simulated Point Pattern
nearest.raster.point

Find Pixel Nearest to a Given Point
rNeymanScott

Simulate Neyman-Scott Process
multiplicity.ppp

Count Multiplicity of Duplicate Points
square

Square Window
plot.plotppm

Plot a plotppm Object Created by plot.ppm
angles.psp

Orientation Angles of Line Segments
pcf.ppp

Pair Correlation Function of Point Pattern
redwoodfull

California Redwoods Point Pattern (Entire Dataset)
nztrees

New Zealand Trees Point Pattern
rmh.default

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

Estimate window from points alone
pairwise.family

Pairwise Interaction Process Family
rpoint

Generate N Random Points
rMaternII

Simulate Matern Model II
print.quad

Print a Quadrature Scheme
rescale.ppp

Convert Point Pattern to Another Unit of Length
plot.psp

plot a Spatial Line Segment Pattern
quadrat.test

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

Data and Code From JRSS Discussion Paper on Residuals
rlabel

Random Re-Labelling of Point Pattern
spatstat.options

Internal Options in Spatstat Package
progressreport

Print Progress Reports
quad.object

Class of Quadrature Schemes
pairdist.ppp

Pairwise distances
reduced.sample

Reduced Sample Estimator using Histogram Data
selfcrossing.psp

Crossing Points in a Line Segment Pattern
inside.owin

Test Whether Points Are Inside A Window
nncross

Nearest Neighbour in Another Point Pattern
rmhcontrol

Set Control Parameters for Metropolis-Hastings Algorithm.
shift

Apply Vector Translation
rMatClust

Simulate Matern Cluster Process
subset.fasp

Extract Subset of Function Array
rotate.psp

Rotate a Line Segment Pattern
rpoisline

Generate Poisson Random Line Process
nbfires

Point Patterns of New Brunswick Forest Fires
solutionset

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

Simulate Simple Sequential Inhibition
summary.ppp

Summary of a Point Pattern Dataset
summary.psp

Summary of a Line Segment Pattern Dataset
subsetget.im

Reset Values in Subset of Image
rpoispp

Generate Poisson Point Pattern
quantile.im

Sample Quantiles of Pixel Image
rmhstart

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

Summarizing a Pixel Image
summary.owin

Summary of a Spatial Window
rshift.psp

Randomly Shift a Line Segment Pattern
rotate.owin

Rotate a Window
superimpose

Superimpose Several Point Patterns
subset.listof

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

Rotate a Point Pattern
subset.im

Extract Subset of Image
subset.psp

Extract Subset of Line Segment Pattern
swedishpines

Swedish Pines Point Pattern
unmark

Remove Marks from a Marked Point Pattern
vertices

Vertices of a Window
unique.ppp

Extract Unique Points from a Spatial Point Pattern
trim.rectangle

Cut margins from rectangle
unitname

Name for Unit of Length
summary.quad

Summarizing a Quadrature Scheme
summary.splitppp

Summary of a Split Point Pattern
update.ppm

Update a Fitted Point Process Model
vcov.ppm

Variance-Covariance Matrix for a Fitted Point Process Model
union.quad

Union of Data and Dummy Points
affine.ppp

Apply Affine Transformation To Point Pattern
Iest

Estimate the I-function
thomas.estK

Fit the Thomas Point Process by Minimum Contrast
coef.ppm

Coefficients of Fitted Point Process Model
density.splitppp

Kernel Smoothed Intensity of Split Point Pattern
envelope

Simulation envelopes of summary function
is.ppm

Test Whether An Object Is A Fitted Point Process Model
mincontrast

Method of Minimum Contrast
pairdist

Pairwise distances
plot.hyperframe

Plot Entries in a Hyperframe
spatstat-internal

Internal spatstat functions
longleaf

Longleaf Pines Point Pattern
markstat

Summarise Marks in Every Neighbourhood in a Point Pattern
localK

Neighbourhood density function
nndist

Nearest neighbour distances
print.owin

Print Brief Details of a Spatial Window
kaplan.meier

Kaplan-Meier Estimator using Histogram Data
rshift.splitppp

Randomly Shift a List of Point Patterns
scanpp

Read Point Pattern From Data File
ppp

Create a Point Pattern
print.psp

Print Brief Details of a Line Segment Pattern Dataset
pppmatching.object

Class of Point Matchings