Learn R Programming

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

spatstat (version 1.13-1)

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.13-1

License

GPL (>= 2)

Maintainer

Adrian Baddeley

Last Published

March 22nd, 2025

Functions in spatstat (1.13-1)

bounding.box.xy

Convex Hull of Points
Kinhom

Inhomogeneous K-function
compatible.im

Test Whether Two Pixel Images Are Compatible
Strauss

The Strauss Point Process Model
Kdot.inhom

Inhomogeneous Multitype K Dot Function
compatible.fv

Test Whether Two Function Objects Are Compatible
Kmulti

Marked K-Function
Kcross

Multitype K Function (Cross-type)
Jest

Estimate the J-function
Gmulti

Marked Nearest Neighbour Distance Function
LennardJones

The Lennard-Jones Potential
Pairwise

Generic Pairwise Interaction model
gridweights

Compute Quadrature Weights Based on Grid Counts
Jdot

Multitype J Function (i-to-any)
DiggleGratton

Diggle-Gratton model
Ord

Generic Ord Interaction model
Fest

Estimate the empty space function F
Gdot

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

The Multitype Strauss Point Process Model
alltypes

Calculate Statistic for All Types in a Multitype Point Pattern
Poisson

Poisson Point Process Model
Kest

K-function
affine.owin

Apply Affine Transformation To Window
as.data.frame.ppp

Coerce Point Pattern to a Data Frame
Kmeasure

Reduced Second Moment Measure
MultiStraussHard

The Multitype/Hard Core Strauss Point Process Model
envelope

Simulation envelopes of summary function
demopat

Artificial Data Point Pattern
Lest

L-function
Kcross.inhom

Inhomogeneous Cross K Function
Saturated

Saturated Pairwise Interaction model
affine.ppp

Apply Affine Transformation To Point Pattern
bramblecanes

Hutchings' Bramble Canes data
applynbd

Apply Function to Every Neighbourhood in a Point Pattern
cut.ppp

Convert Point Pattern Marks from Numeric to Factor
longleaf

Longleaf Pines Point Pattern
anova.ppm

ANOVA for Fitted Point Process Models
Gest

Nearest Neighbour Distance Function G
PairPiece

The Piecewise Constant Pairwise Interaction Point Process Model
Geyer

Geyer's Saturation Point Process Model
cut.im

Convert Pixel Image from Numeric to Factor
area.owin

Area of a Window
append.psp

Combine Two Line Segment Patterns
copper

Berman-Huntington points and lines data
Kdot

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

Take Complement of a Window
distmap.psp

Distance Map of Line Segment Pattern
is.marked

Test Whether Marks Are Present
Jmulti

Marked J Function
Linhom

L-function
StraussHard

The Strauss / Hard Core Point Process Model
OrdThresh

Ord's Interaction model
as.owin

Convert Data To Class owin
bounding.box

Bounding Box of a Window or Point Pattern
affine

Apply Affine Transformation
allstats

Calculate four standard summary functions of a point pattern.
centroid.owin

Centroid of a window
corners

Corners of a rectangle
duplicated.ppp

Determine Duplicated Points in a Spatial Point Pattern
localK

Neighbourhood density function
angles.psp

Orientation Angles of Line Segments
as.mask

Pixel Image Approximation of a Window
data.ppm

Extract Original Data from a Fitted Point Process Model
ewcdf

Weighted Empirical Cumulative Distribution Function
SatPiece

Piecewise Constant Saturated Pairwise Interaction Point Process Model
cells

Biological Cells Point Pattern
as.im

Convert to Pixel Image
finpines

Pine saplings in Finland.
spatstat-deprecated

Deprecated spatstat functions
Softcore

The Soft Core Point Process Model
Iest

Estimate the I-function
areadiff

Difference of Disc Areas
km.rs

Kaplan-Meier and Reduced Sample Estimator using Histograms
spatstat

The Spatstat Package
clickpoly

Interactively Define a Polygon
is.marked.ppm

Test Whether A Point Process Model is Marked
chorley

Chorley-Ribble Cancer Data
affine.psp

Apply Affine Transformation To Line Segment Pattern
dilate.owin

Dilate a Window
bei

Tropical rain forest trees
as.psp

Convert Data To Class psp
as.matrix.im

Convert Pixel Image to Matrix
plot.fv

Plot Function Valuesn
concatxy

Concatenate x,y Coordinate Vectors
anemones

Beadlet Anemones Data
crossdist.ppp

Pairwise distances between two different point patterns
contour.im

Contour plot of pixel image
eval.hyper

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

Kernel Smoothing of Line Segment Pattern
mean.im

Mean Pixel Value in an Image
as.ppp

Convert Data To Class ppp
density.ppp

Kernel Smoothed Intensity of Point Pattern
distmap.ppp

Distance Map of Point Pattern
inside.owin

Test Whether Points Are Inside A Window
subset.ppp

Extract or Replace Subset of Point Pattern
bdist.pixels

Distance to Boundary of Window
dummy.ppm

Extract Dummy Points Used to Fit a Point Process Model
BadGey

Hybrid Geyer Point Process Model
distmap

Distance Map
Gcross

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

Basis for Harmonic Functions
ganglia

Beta Ganglion Cells in Cat Retina, Old Version
clickppp

Interactively Add Points
pairdist

Pairwise distances
disc

Circular Window
pcf.fv

Pair Correlation Function obtained from K Function
Kest.fft

K-function using FFT
as.rectangle

Window Frame
Jcross

Multitype J Function (i-to-j)
bdist.points

Distance to Boundary of Window
gridcentres

Rectangular grid of points
markstat

Summarise Marks in Every Neighbourhood in a Point Pattern
crossdist.psp

Pairwise distances between two different line segment patterns
nndist

Nearest neighbour distances
im

Create a Pixel Image Object
crossing.psp

Crossing Points of Two Line Segment Patterns
predict.ppm

Prediction from a Fitted Point Process Model
diagnose.ppm

Diagnostic Plots for Fitted Point Process Model
inforder.family

Infinite Order Interaction Family
dirichlet.weights

Compute Quadrature Weights Based on Dirichlet Tessellation
is.multitype

Test whether Object is Multitype
AreaInter

The Area Interaction Point Process Model
coef.ppm

Coefficients of Fitted Point Process Model
ants

Harkness-Isham ants' nests data
mincontrast

Method of Minimum Contrast
amacrine

Hughes' Amacrine Cell Data
hamster

Aherne's hamster tumour data
distmap.owin

Distance Map of Window
fasp.object

Function Arrays for Spatial Patterns
fv.object

Data Frames of Function Values
rSSI

Simulate Simple Sequential Inhibition
eem

Exponential Energy Marks
pcf

Pair Correlation Function
markcorr

Mark Correlation Function
hist.im

Histogram of Pixel Values in an Image
diameter

Diameter of a Window
fitin.ppm

Extract the Interaction from a Fitted Point Process Model
owin

Create a Window
crossdist

Pairwise distances
default.dummy

Generate a Default Pattern of Dummy Points
lurking

Lurking variable plot
is.marked.ppp

Test Whether A Point Pattern is Marked
subsetget.im

Reset Values in Subset of Image
erode.owin

Erode a Window
betacells

Beta Ganglion Cells in Cat Retina
convexhull.xy

Convex Hull of Points
clarkevans

Clark and Evans Aggregation Index
is.multitype.ppm

Test Whether A Point Process Model is Multitype
nbfires

Point Patterns of New Brunswick Forest Fires
is.ppm

Test Whether An Object Is A Fitted Point Process Model
rotate.ppp

Rotate a Point Pattern
letterR

Window in Shape of Letter R
is.im

Test Whether An Object Is A Pixel Image
trim.rectangle

Cut margins from rectangle
is.ppp

Test Whether An Object Is A Point Pattern
reduced.sample

Reduced Sample Estimator using Histogram Data
multiplicity.ppp

Count Multiplicity of Duplicate Points
ripras

Estimate window from points alone
print.ppp

Print Brief Details of a Point Pattern Dataset
lansing

Lansing Woods Point Pattern
hyperframe

Hyper Data Frame
japanesepines

Japanese Pines Point Pattern
nncorr

Nearest-Neighbour Correlation of Marked Point Pattern
midpoints.psp

Midpoints of Line Segment Pattern
pppmatching

Create a Point Matching
nztrees

New Zealand Trees Point Pattern
kaplan.meier

Kaplan-Meier Estimator using Histogram Data
vcov.ppm

Variance-Covariance Matrix for a Fitted Point Process Model
nearest.raster.point

Find Pixel Nearest to a Given Point
pcf.fasp

Pair Correlation Function obtained from array of K functions
endpoints.psp

Endpoints of Line Segment Pattern
identify.ppp

Identify Points in a Point Pattern
fitted.ppm

Fitted Conditional Intensity for Point Process Model
pairwise.family

Pairwise Interaction Process Family
logLik.ppm

Log Likelihood for Poisson Point Process Model
levelset

Level Set of a Pixel Image
nncross

Nearest Neighbour in Another Point Pattern
is.multitype.ppp

Test Whether A Point Pattern is Multitype
ord.family

Ord Interaction Process Family
matchingdist

Distance for a Point Pattern Matching
plot.owin

Plot a Spatial Window
progressreport

Print Progress Reports
pairdist.psp

Pairwise distances between line segments
crossdist.default

Pairwise distances between two different sets of points
spatstat-internal

Internal spatstat functions
marktable

Tabulate Marks in Neighbourhood of Every Point in a Point Pattern
print.im

Print Brief Details of an Image
owin.object

Class owin
ppm

Fit Point Process Model to Data
density.splitppp

Kernel Smoothed Intensity of Split Point Pattern
eroded.areas

Areas of Morphological Erosions
discretise

Safely Convert Point Pattern Window to Binary Mask
rescue.rectangle

Convert Window Back To Rectangle
im.object

Class of Images
pppdist

Distance Between Two Point Patterns
rStrauss

Perfect Simulation of the Strauss Process
rsyst

Simulate systematic random point pattern
rThomas

Simulate Thomas Process
is.subset.owin

Determine Whether One Window is Contained In Another
matclust.estK

Fit the Matern Cluster Point Process by Minimum Contrast
unmark

Remove Marks from a Marked Point Pattern
ppp

Create a Point Pattern
runifdisc

Generate N Uniform Random Points in a Disc
kstest.ppm

Kolmogorov-Smirnov Test for Point Process Model
rescale.owin

Convert Window to Another Unit of Length
intersect.owin

Intersection or Union of Two Windows
eval.fv

Evaluate Expression Involving Functions
humberside

Humberside Data on Childhood Leukaemia and Lymphoma
nndist.psp

Nearest neighbour distances between line segments
expand.owin

Expand Window By Factor
rmh.default

Simulate Point Process Models using the Metropolis-Hastings Algorithm.
rshift.ppp

Randomly Shift a Point Pattern
qqplot.ppm

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

Nearest neighbour
lengths.psp

Lengths of Line Segments
pairdist.ppp

Pairwise distances
quantile.im

Sample Quantiles of Pixel Image
eval.im

Evaluate Expression Involving Pixel Images
is.owin

Test Whether An Object Is A Window
pcf.ppp

Pair Correlation Function of Point Pattern
plot.im

Plot a Pixel Image
model.matrix.ppm

Extract Design Matrix from Point Process Model
plot.fasp

Plot a Function Array
quad.object

Class of Quadrature Schemes
quadrat.test

Chi-Squared Dispersion Test for Spatial Point Pattern Based on Quadrat Counts
plot.quad

plot a Spatial Quadrature Scheme
rMaternII

Simulate Matern Model II
print.ppm

Print a Fitted Point Process Model
plot.hyperframe

Plot Entries in a Hyperframe
shift.psp

Apply Vector Translation To Line Segment Pattern
rmhcontrol

Set Control Parameters for Metropolis-Hastings Algorithm.
stieltjes

Compute Integral of Function Against Cumulative Distribution
rstrat

Simulate Stratified Random Point Pattern
subset.splitppp

Extract or Replace Sub-Patterns
rmh.ppm

Simulate from a Fitted Point Process Model
pairsat.family

Saturated Pairwise Interaction Point Process Family
plot.ppp

plot a Spatial Point Pattern
selfcrossing.psp

Crossing Points in a Line Segment Pattern
residualspaper

Data and Code From JRSS Discussion Paper on Residuals
ppp.object

Class of Point Patterns
quadratcount

Quadrat counting for a point pattern
print.psp

Print Brief Details of a Line Segment Pattern Dataset
swedishpines

Swedish Pines Point Pattern
smooth.ppp

Spatial smoothing of observations at irregular points
lgcp.estK

Fit a Log-Gaussian Cox Point Process by Minimum Contrast
update.ppm

Update a Fitted Point Process Model
pairdist.default

Pairwise distances
rGaussPoisson

Simulate Gauss-Poisson Process
plot.psp

plot a Spatial Line Segment Pattern
rlabel

Random Re-Labelling of Point Pattern
psp.object

Class of Line Segment Patterns
pppmatching.object

Class of Point Matchings
plot.listof

Plot a List of Things
plot.plotppm

Plot a plotppm Object Created by plot.ppm
shift.ppp

Apply Vector Translation To Point Pattern
summary.owin

Summary of a Spatial Window
print.quad

Print a Quadrature Scheme
rthin

Random Thinning
rotate

Rotate
unitname

Name for Unit of Length
rmhstart

Determine Initial State for Metropolis-Hastings Simulation.
rMaternI

Simulate Matern Model I
print.owin

Print Brief Details of a Spatial Window
ponderosa

Ponderosa Pine Tree Point Pattern
rmhmodel.ppm

Interpret Fitted Model for Metropolis-Hastings Simulation.
spokes

Spokes pattern of dummy points
rMatClust

Simulate Matern Cluster Process
reach

Interaction Distance of a Point Process
summary.im

Summarizing a Pixel Image
residuals.ppm

Residuals for Fitted Point Process Model
rotate.owin

Rotate a Window
rcell

Simulate Baddeley-Silverman Cell Process
rshift

Random Shift
rshift.psp

Randomly Shift a Line Segment Pattern
ppm.object

Class of Fitted Point Process Models
subset.im

Extract Subset of Image
subset.fasp

Extract Subset of Function Array
spatstat.options

Internal Options in Spatstat Package
persp.im

Perspective Plot of Pixel Image
rNeymanScott

Simulate Neyman-Scott Process
scanpp

Read Point Pattern From Data File
rmpoispp

Generate Multitype Poisson Point Pattern
redwood

California Redwoods Point Pattern (Ripley's Subset)
plot.splitppp

Plot a List of Point Patterns
model.images

Compute Images of Constructed Covariates
shift

Apply Vector Translation
rmh

Simulate point patterns using the Metropolis-Hastings algorithm.
quad.ppm

Extract Quadrature Scheme Used to Fit a Point Process Model
quadscheme

Generate a Quadrature Scheme from a Point Pattern
rescale.ppp

Convert Point Pattern to Another Unit of Length
rmhmodel.default

Build Point Process Model for Metropolis-Hastings Simulation.
rpoisline

Generate Poisson Random Line Process
rmhmodel.list

Define Point Process Model for Metropolis-Hastings Simulation.
rmhmodel

Define Point Process Model for Metropolis-Hastings Simulation.
plot.ppm

plot a Fitted Point Process Model
rshift.splitppp

Randomly Shift a List of Point Patterns
union.quad

Union of Data and Dummy Points
interp.im

Interpolate a Pixel Image
rlinegrid

Generate grid of parallel lines with random displacement
unique.ppp

Extract Unique Points from a Spatial Point Pattern
simdat

Simulated Point Pattern
rescale.psp

Convert Line Segment Pattern to Another Unit of Length
setmarks

Set or Reset the Marks in a Point Pattern
setcov

Set Covariance of a Window
rpoint

Generate N Random Points
psp

Create a Line Segment Pattern
subset.psp

Extract Subset of Line Segment Pattern
profilepl

Profile Maximum Pseudolikelihood
rpoispp

Generate Poisson Point Pattern
square

Square Window
suffstat

Sufficient Statistic of Point Process Model
rescale

Convert dataset to another unit of length
subset.listof

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

Rotate a Line Segment Pattern
superimpose

Superimpose Several Point Patterns
shift.im

Apply Vector Translation To Pixel Image
thomas.estK

Fit the Thomas Point Process by Minimum Contrast
runifpoint

Generate N Uniform Random Points
solutionset

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

Vertices of a Window
rmpoint

Generate N Random Multitype Points
shift.owin

Apply Vector Translation To Window
summary.listof

Summary of a List of Things
redwoodfull

California Redwoods Point Pattern (Entire Dataset)
raster.x

Cartesian Coordinates for a Pixel Raster
summary.psp

Summary of a Line Segment Pattern Dataset
spruces

Spruces Point Pattern
summary.quad

Summarizing a Quadrature Scheme
split.ppp

Divide Point Pattern into Sub-patterns
summary.ppp

Summary of a Point Pattern Dataset
subset.fv

Extract Subset of Function Values
summary.ppm

Summarizing a Fitted Point Process Model
summary.splitppp

Summary of a Split Point Pattern