Learn R Programming

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

spatstat (version 1.11-7)

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 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.11-7

License

GPL version 2 or newer

Maintainer

Adrian Baddeley

Last Published

March 22nd, 2025

Functions in spatstat (1.11-7)

Kmeasure

Reduced Second Moment Measure
affine

Apply Affine Transformation
ganglia

Beta Ganglion Cells in Cat Retina, Old Version
as.matrix.im

Convert Pixel Image to Matrix
allstats

Calculate four standard summary functions of a point pattern.
hist.im

Histogram of Pixel Values in an Image
fv.object

Data Frames of Function Values
Kmulti

Marked K-Function
ewcdf

Weighted Empirical Cumulative Distribution Function
Geyer

Geyer's Saturation Point Process Model
spatstat

The Spatstat Package
alltypes

Calculate Statistic for All Types in a Multitype Point Pattern
Gest

Nearest Neighbour Distance Function G
PairPiece

The Piecewise Constant Pairwise Interaction Point Process Model
cells

Biological Cells Point Pattern
data.ppm

Extract Original Data from a Fitted Point Process Model
Kcross

Multitype K Function (Cross-type)
append.psp

Combine Two Line Segment Patterns
cut.ppp

Convert Point Pattern Marks from Numeric to Factor
area.owin

Area of a Window
affine.owin

Apply Affine Transformation To Window
Iest

Estimate the I-function
bounding.box.xy

Convex Hull of Points
gridcentres

Rectangular grid of points
anova.ppm

ANOVA for Fitted Point Process Models
as.ppp

Convert Data To Class ppp
DiggleGratton

Diggle-Gratton model
is.marked.ppp

Test Whether A Point Pattern is Marked
diameter

Diameter of a Window
default.dummy

Generate a Default Pattern of Dummy Points
quad.object

Class of Quadrature Schemes
is.multitype.ppp

Test Whether A Point Pattern is Multitype
disc

Circular Window
is.ppm

Test Whether An Object Is A Fitted Point Process Model
owin

Create a Window
rMaternI

Simulate Matern Model I
clickppp

Interactively Add Points
identify.ppp

Identify Points in a Point Pattern
dummy.ppm

Extract Dummy Points Used to Fit a Point Process Model
interp.im

Interpolate a Pixel Image
spatstat-deprecated

Deprecated spatstat functions
plot.ppp

plot a Spatial Point Pattern
betacells

Beta Ganglion Cells in Cat Retina
redwoodfull

California Redwoods Point Pattern (Entire Dataset)
distmap

Distance Map
eem

Exponential Energy Marks
inside.owin

Test Whether Points Are Inside A Window
copper

Berman-Huntington points and lines data
im.object

Class of Images
plot.plotppm

Plot a plotppm Object Created by plot.ppm
redwood

California Redwoods Point Pattern (Ripley's Subset)
Saturated

Saturated Pairwise Interaction model
is.owin

Test Whether An Object Is A Window
gridweights

Compute Quadrature Weights Based on Grid Counts
rcell

Simulate Baddeley-Silverman Cell Process
rMaternII

Simulate Matern Model II
bounding.box

Bounding Box of a Window or Point Pattern
im

Create a Pixel Image Object
rMatClust

Simulate Matern Cluster Process
rotate.ppp

Rotate a Point Pattern
intersect.owin

Intersection or Union of Two Windows
residuals.ppm

Residuals for Fitted Point Process Model
nearest.raster.point

Find Pixel Nearest to a Given Point
rThomas

Simulate Thomas Process
ripras

Estimate window from points alone
rsyst

Simulate systematic random point pattern
rshift.splitppp

Randomly Shift a List of Point Patterns
rStrauss

Perfect Simulation of the Strauss Process
is.im

Test Whether An Object Is A Pixel Image
split.ppp

Divide Point Pattern into Sub-patterns
ppm

Fit Point Process Model to Data
rSSI

Simulate Simple Sequential Inhibition
mean.im

Mean Pixel Value in an Image
plot.splitppp

Plot a List of Point Patterns
simdat

Simulated Point Pattern
is.multitype.ppm

Test Whether A Point Process Model is Multitype
rshift

Random Shift
is.marked

Test Whether Marks Are Present
pairdist

Pairwise distances
print.owin

Print Brief Details of a Spatial Window
setmarks

Set or Reset the Marks in a Point Pattern
summary.listof

Summary of a List of Things
pairwise.family

Pairwise Interaction Process Family
pairdist.ppp

Pairwise distances
ord.family

Ord Interaction Process Family
pppdist

Optimal Match Between Two Point Patterns
psp.object

Class of Line Segment Patterns
print.psp

Print Brief Details of a Line Segment Pattern Dataset
Jest

Estimate the J-function
rmhmodel.default

Build Point Process Model for Metropolis-Hastings Simulation.
quadscheme

Generate a Quadrature Scheme from a Point Pattern
plot.im

Plot a Pixel Image
psp

Create a Line Segment Pattern
levelset

Level Set of a Pixel Image
rescue.rectangle

Convert Window Back To Rectangle
plot.quad

plot a Spatial Quadrature Scheme
Kest

K-function
subset.ppp

Extract or Replace Subset of Point Pattern
thomas.estK

Fit the Thomas Point Process by Minimum Contrast
residualspaper

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

Simulate from a Fitted Point Process Model
rotate.psp

Rotate a Line Segment Pattern
subset.listof

Extract or Replace Subset of a List of Things
spruces

Spruces Point Pattern
rpoisline

Generate Poisson Random Line Process
shift.psp

Apply Vector Translation To Line Segment Pattern
Kest.fft

K-function using FFT
square

Square Window
clickpoly

Interactively Define a Polygon
rmpoispp

Generate Multitype Poisson Point Pattern
summary.splitppp

Summary of a Split Point Pattern
summary.psp

Summary of a Line Segment Pattern Dataset
as.mask

Pixel Image Approximation of a Window
angles.psp

Orientation Angles of Line Segments
owin.object

Class owin
print.quad

Print a Quadrature Scheme
applynbd

Apply Function to Every Neighbourhood in a Point Pattern
quad.ppm

Extract Quadrature Scheme Used to Fit a Point Process Model
pcf.fasp

Pair Correlation Function obtained from array of K functions
compatible.im

Test Whether Two Pixel Images Are Compatible
crossdist.default

Pairwise distances between two different sets of points
compatible.fv

Test Whether Two Function Objects Are Compatible
affine.psp

Apply Affine Transformation To Line Segment Pattern
rescale.psp

Convert Line Segment Pattern to Another Unit of Length
Kdot

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

Kernel Smoothed Intensity of Point Pattern
persp.im

Perspective Plot of Pixel Image
Pairwise

Generic Pairwise Interaction model
crossdist

Pairwise distances
expand.owin

Expand Window By Factor
corners

Corners of a rectangle
multiplicity.ppp

Count Multiplicity of Duplicate Points
midpoints.psp

Midpoints of Line Segment Pattern
MultiStraussHard

The Multitype/Hard Core Strauss Point Process Model
dirichlet.weights

Compute Quadrature Weights Based on Dirichlet Tessellation
endpoints.psp

Endpoints of Line Segment Pattern
ks.test.ppm

Kolmogorov-Smirnov Test for Point Process Model
lengths.psp

Lengths of Line Segments
japanesepines

Japanese Pines Point Pattern
pcf

Pair Correlation Function
nztrees

New Zealand Trees Point Pattern
centroid.owin

Centroid of a window
subset.fv

Extract Subset of Function Values
reach

Interaction Distance of a Point Process
rshift.ppp

Randomly Shift a Point Pattern
convexhull.xy

Convex Hull of Points
subset.im

Extract Subset of Image
rmh.default

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

Summarise Marks in Every Neighbourhood in a Point Pattern
mincontrast

Method of Minimum Contrast
is.subset.owin

Determine Whether One Window is Contained In Another
rpoispp

Generate Poisson Point Pattern
density.splitppp

Kernel Smoothed Intensity of Split Point Pattern
nndist.psp

Nearest neighbour distances between line segments
envelope

Simulation envelopes of summary function
shift.ppp

Apply Vector Translation To Point Pattern
discretise

Safely Convert Point Pattern Window to Binary Mask
print.ppp

Print Brief Details of a Point Pattern Dataset
runifpoint

Generate N Uniform Random Points
plot.owin

Plot a Spatial Window
rescale.ppp

Convert Point Pattern to Another Unit of Length
subset.psp

Extract Subset of Line Segment Pattern
union.quad

Union of Data and Dummy Points
is.multitype

Test whether Object is Multitype
trim.rectangle

Cut margins from rectangle
rlinegrid

Generate grid of parallel lines with random displacement
quadrat.test

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

Convert dataset to another unit of length
rotate

Rotate
subset.fasp

Extract Subset of Function Array
rthin

Random Thinning
rstrat

Simulate Stratified Random Point Pattern
vertices

Vertices of a Window
swedishpines

Swedish Pines Point Pattern
crossdist.psp

Pairwise distances between two different line segment patterns
as.im

Convert to Pixel Image
humberside

Humberside Data on Childhood Leukaemia and Lymphoma
km.rs

Kaplan-Meier and Reduced Sample Estimator using Histograms
lansing

Lansing Woods Point Pattern
plot.fasp

Plot a Function Array
ppp

Create a Point Pattern
Gmulti

Marked Nearest Neighbour Distance Function
Jmulti

Marked J Function
plot.ppm

plot a Fitted Point Process Model
rmhstart

Determine Initial State for Metropolis-Hastings Simulation.
solutionset

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

Variance-Covariance Matrix for a Fitted Point Process Model
Kinhom

Inhomogeneous K-function
LennardJones

The Lennard-Jones Potential
distmap.owin

Distance Map of Window
contour.im

Contour plot of pixel image
duplicated.ppp

Determine Duplicated Points in a Spatial Point Pattern
scanpp

Read Point Pattern From Data File
affine.ppp

Apply Affine Transformation To Point Pattern
as.owin

Convert Data To Class owin
demopat

Artificial Data Point Pattern
crossing.psp

Crossing Points of Two Line Segment Patterns
concatxy

Concatenate x,y Coordinate Vectors
distmap.ppp

Distance Map of Point Pattern
ants

Harkness-Isham ants' nests data
fitin.ppm

Extract the Interaction from a Fitted Point Process Model
longleaf

Longleaf Pines Point Pattern
predict.ppm

Prediction from a Fitted Point Process Model
hamster

Aherne's hamster tumour data
profilepl

Profile Maximum Pseudolikelihood
reduced.sample

Reduced Sample Estimator using Histogram Data
letterR

Window in Shape of Letter R
selfcrossing.psp

Crossing Points in a Line Segment Pattern
lurking

Lurking variable plot
pcf.ppp

Pair Correlation Function of Point Pattern
shift

Apply Vector Translation
superimpose

Superimpose Several Point Patterns
update.ppm

Update a Fitted Point Process Model
setcov

Set Covariance of a Window
progressreport

Print Progress Reports
raster.x

Cartesian Coordinates for a Pixel Raster
spatstat.options

Internal Options in Spatstat Package
qqplot.ppm

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

Randomly Shift a Line Segment Pattern
shift.owin

Apply Vector Translation To Window
unmark

Remove Marks from a Marked Point Pattern
Strauss

The Strauss Point Process Model
bdist.points

Distance to Boundary of Window
erode.owin

Erode a Window
markcorr

Mark Correlation Function
dilate.owin

Dilate a Window
eval.fv

Evaluate Expression Involving Functions
harmonic

Basis for Harmonic Functions
logLik.ppm

Log Likelihood for Poisson Point Process Model
lgcp.estK

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

Nearest Neighbour in Another Point Pattern
rNeymanScott

Simulate Neyman-Scott Process
nnwhich

Nearest neighbour
runifdisc

Generate N Uniform Random Points in a Disc
rmhmodel.list

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

Summary of a Point Pattern Dataset
subsetget.im

Reset Values in Subset of Image
summary.owin

Summary of a Spatial Window
as.psp

Convert Data To Class psp
crossdist.ppp

Pairwise distances between two different point patterns
eval.im

Evaluate Expression Involving Pixel Images
plot.listof

Plot a List of Things
rmpoint

Generate N Random Multitype Points
rmhmodel.ppm

Interpret Fitted Model for Metropolis-Hastings Simulation.
units

Name for Unit of Length
subset.splitppp

Extract or Replace Sub-Patterns
Fest

Estimate the empty space function F
Jdot

Multitype J Function (i-to-any)
Jcross

Multitype J Function (i-to-j)
Kdot.inhom

Inhomogeneous Multitype K Dot Function
Softcore

The Soft Core Point Process Model
distmap.psp

Distance Map of Line Segment Pattern
fitted.ppm

Fitted Conditional Intensity for Point Process Model
spatstat-internal

Internal spatstat functions
pairdist.default

Pairwise distances
pcf.fv

Pair Correlation Function obtained from K Function
plot.fv

Plot Function Valuesn
print.im

Print Brief Details of an Image
rlabel

Random Re-Labelling of Point Pattern
rpoint

Generate N Random Points
summary.ppm

Summarizing a Fitted Point Process Model
unique.ppp

Extract Unique Points from a Spatial Point Pattern
rmhcontrol

Set Control Parameters for Metropolis-Hastings Algorithm.
rmhmodel

Define Point Process Model for Metropolis-Hastings Simulation.
bei

Tropical rain forest trees
Kcross.inhom

Inhomogeneous Cross K Function
density.psp

Kernel Smoothing of Line Segment Pattern
nncorr

Nearest-Neighbour Correlation of Marked Point Pattern
amacrine

Hughes' Amacrine Cell Data
ppm.object

Class of Fitted Point Process Models
matclust.estK

Fit the Matern Cluster Point Process by Minimum Contrast
Poisson

Poisson Point Process Model
rotate.owin

Rotate a Window
kaplan.meier

Kaplan-Meier Estimator using Histogram Data
diagnose.ppm

Diagnostic Plots for Fitted Point Process Model
anemones

Beadlet Anemones Data
Gdot

Multitype Nearest Neighbour Distance Function (i-to-any)
is.ppp

Test Whether An Object Is A Point Pattern
cut.im

Convert Pixel Image from Numeric to Factor
rescale.owin

Convert Window to Another Unit of Length
as.rectangle

Window Frame
shift.im

Apply Vector Translation To Pixel Image
summary.im

Summarizing a Pixel Image
pairsat.family

Saturated Pairwise Interaction Point Process Family
quantile.im

Sample Quantiles of Pixel Image
Ord

Generic Ord Interaction model
chorley

Chorley-Ribble Cancer Data
MultiStrauss

The Multitype Strauss Point Process Model
pairdist.psp

Pairwise distances between line segments
bdist.pixels

Distance to Boundary of Window
nbfires

Point Patterns of New Brunswick Forest Fires
fasp.object

Function Arrays for Spatial Patterns
plot.psp

plot a Spatial Line Segment Pattern
coef.ppm

Coefficients of Fitted Point Process Model
spokes

Spokes pattern of dummy points
OrdThresh

Ord's Interaction model
StraussHard

The Strauss / Hard Core Point Process Model
Gcross

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

Pine saplings in Finland.
clarkevans

Clark and Evans Aggregation Index
is.marked.ppm

Test Whether A Point Process Model is Marked
eroded.areas

Areas of Morphological Erosions
nndist

Nearest neighbour distances
print.ppm

Print a Fitted Point Process Model
rmh

Simulate point patterns using the Metropolis-Hastings algorithm.
ppp.object

Class of Point Patterns
summary.quad

Summarizing a Quadrature Scheme
suffstat

Sufficient Statistic of Point Process Model
bramblecanes

Hutchings' Bramble Canes data
complement.owin

Take Complement of a Window
quadratcount

Quadrat counting for a point pattern