Learn R Programming

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

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

License

GPL (>= 2)

Maintainer

Adrian Baddeley

Last Published

March 22nd, 2025

Functions in spatstat (1.12-7)

crossdist.default

Pairwise distances between two different sets of points
eval.fv

Evaluate Expression Involving Functions
Kdot

Multitype K Function (i-to-any)
matclust.estK

Fit the Matern Cluster Point Process by Minimum Contrast
Kcross

Multitype K Function (Cross-type)
rcell

Simulate Baddeley-Silverman Cell Process
Saturated

Saturated Pairwise Interaction model
PairPiece

The Piecewise Constant Pairwise Interaction Point Process Model
as.im

Convert to Pixel Image
Kdot.inhom

Inhomogeneous Multitype K Dot Function
StraussHard

The Strauss / Hard Core Point Process Model
Gcross

Multitype Nearest Neighbour Distance Function (i-to-j)
as.mask

Pixel Image Approximation of a Window
corners

Corners of a rectangle
rmh

Simulate point patterns using the Metropolis-Hastings algorithm.
anemones

Beadlet Anemones Data
Jcross

Multitype J Function (i-to-j)
Linhom

L-function
plot.ppm

plot a Fitted Point Process Model
Gest

Nearest Neighbour Distance Function G
Fest

Estimate the empty space function F
AreaInter

The Area Interaction Point Process Model
Geyer

Geyer's Saturation Point Process Model
inside.owin

Test Whether Points Are Inside A Window
solutionset

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

Generate Poisson Random Line Process
MultiStraussHard

The Multitype/Hard Core Strauss Point Process Model
ants

Harkness-Isham ants' nests data
marktable

Tabulate Marks in Neighbourhood of Every Point in a Point Pattern
distmap.psp

Distance Map of Line Segment Pattern
plot.owin

Plot a Spatial Window
plot.hyperframe

Plot Entries in a Hyperframe
as.matrix.im

Convert Pixel Image to Matrix
concatxy

Concatenate x,y Coordinate Vectors
Kinhom

Inhomogeneous K-function
cells

Biological Cells Point Pattern
pairdist.ppp

Pairwise distances
copper

Berman-Huntington points and lines data
rMaternI

Simulate Matern Model I
betacells

Beta Ganglion Cells in Cat Retina
areadiff

Difference of Disc Areas
markcorr

Mark Correlation Function
ewcdf

Weighted Empirical Cumulative Distribution Function
redwoodfull

California Redwoods Point Pattern (Entire Dataset)
eroded.areas

Areas of Morphological Erosions
cut.ppp

Convert Point Pattern Marks from Numeric to Factor
nbfires

Point Patterns of New Brunswick Forest Fires
kstest.ppm

Kolmogorov-Smirnov Test for Point Process Model
quadscheme

Generate a Quadrature Scheme from a Point Pattern
coef.ppm

Coefficients of Fitted Point Process Model
mean.im

Mean Pixel Value in an Image
as.owin

Convert Data To Class owin
affine.owin

Apply Affine Transformation To Window
redwood

California Redwoods Point Pattern (Ripley's Subset)
LennardJones

The Lennard-Jones Potential
as.psp

Convert Data To Class psp
lansing

Lansing Woods Point Pattern
bounding.box.xy

Convex Hull of Points
centroid.owin

Centroid of a window
gridweights

Compute Quadrature Weights Based on Grid Counts
Kmeasure

Reduced Second Moment Measure
amacrine

Hughes' Amacrine Cell Data
Jdot

Multitype J Function (i-to-any)
lurking

Lurking variable plot
simdat

Simulated Point Pattern
density.psp

Kernel Smoothing of Line Segment Pattern
harmonic

Basis for Harmonic Functions
pcf.fasp

Pair Correlation Function obtained from array of K functions
crossdist

Pairwise distances
markstat

Summarise Marks in Every Neighbourhood in a Point Pattern
plot.fasp

Plot a Function Array
kaplan.meier

Kaplan-Meier Estimator using Histogram Data
quad.ppm

Extract Quadrature Scheme Used to Fit a Point Process Model
rmh.default

Simulate Point Process Models using the Metropolis-Hastings Algorithm.
compatible.fv

Test Whether Two Function Objects Are Compatible
psp.object

Class of Line Segment Patterns
nztrees

New Zealand Trees Point Pattern
intersect.owin

Intersection or Union of Two Windows
is.owin

Test Whether An Object Is A Window
print.owin

Print Brief Details of a Spatial Window
rSSI

Simulate Simple Sequential Inhibition
pairwise.family

Pairwise Interaction Process Family
nncorr

Nearest-Neighbour Correlation of Marked Point Pattern
spatstat-internal

Internal spatstat functions
pairsat.family

Saturated Pairwise Interaction Point Process Family
ppm.object

Class of Fitted Point Process Models
print.im

Print Brief Details of an Image
im.object

Class of Images
rsyst

Simulate systematic random point pattern
area.owin

Area of a Window
multiplicity.ppp

Count Multiplicity of Duplicate Points
ripras

Estimate window from points alone
eem

Exponential Energy Marks
pppmatching

Create a Point Matching
hist.im

Histogram of Pixel Values in an Image
km.rs

Kaplan-Meier and Reduced Sample Estimator using Histograms
Jest

Estimate the J-function
owin

Create a Window
rlabel

Random Re-Labelling of Point Pattern
reach

Interaction Distance of a Point Process
crossdist.psp

Pairwise distances between two different line segment patterns
Poisson

Poisson Point Process Model
rGaussPoisson

Simulate Gauss-Poisson Process
bei

Tropical rain forest trees
Iest

Estimate the I-function
dilate.owin

Dilate a Window
rStrauss

Perfect Simulation of the Strauss Process
quadratcount

Quadrat counting for a point pattern
rpoispp

Generate Poisson Point Pattern
lengths.psp

Lengths of Line Segments
print.ppm

Print a Fitted Point Process Model
quantile.im

Sample Quantiles of Pixel Image
Lest

L-function
summary.listof

Summary of a List of Things
eval.im

Evaluate Expression Involving Pixel Images
plot.fv

Plot Function Valuesn
rmh.ppm

Simulate from a Fitted Point Process Model
summary.im

Summarizing a Pixel Image
fasp.object

Function Arrays for Spatial Patterns
summary.ppp

Summary of a Point Pattern Dataset
plot.listof

Plot a List of Things
rshift.ppp

Randomly Shift a Point Pattern
duplicated.ppp

Determine Duplicated Points in a Spatial Point Pattern
interp.im

Interpolate a Pixel Image
summary.psp

Summary of a Line Segment Pattern Dataset
subset.fv

Extract Subset of Function Values
spatstat.options

Internal Options in Spatstat Package
distmap.owin

Distance Map of Window
split.ppp

Divide Point Pattern into Sub-patterns
ppp.object

Class of Point Patterns
OrdThresh

Ord's Interaction model
summary.quad

Summarizing a Quadrature Scheme
default.dummy

Generate a Default Pattern of Dummy Points
rmpoispp

Generate Multitype Poisson Point Pattern
convexhull.xy

Convex Hull of Points
density.splitppp

Kernel Smoothed Intensity of Split Point Pattern
is.multitype.ppm

Test Whether A Point Process Model is Multitype
density.ppp

Kernel Smoothed Intensity of Point Pattern
expand.owin

Expand Window By Factor
bdist.points

Distance to Boundary of Window
diagnose.ppm

Diagnostic Plots for Fitted Point Process Model
thomas.estK

Fit the Thomas Point Process by Minimum Contrast
ganglia

Beta Ganglion Cells in Cat Retina, Old Version
Gdot

Multitype Nearest Neighbour Distance Function (i-to-any)
inforder.family

Infinite Order Interaction Family
rlinegrid

Generate grid of parallel lines with random displacement
pcf

Pair Correlation Function
ponderosa

Ponderosa Pine Tree Point Pattern
rMaternII

Simulate Matern Model II
setcov

Set Covariance of a Window
is.ppp

Test Whether An Object Is A Point Pattern
superimpose

Superimpose Several Point Patterns
mincontrast

Method of Minimum Contrast
is.marked.ppm

Test Whether A Point Process Model is Marked
hyperframe

Hyper Data Frame
affine.ppp

Apply Affine Transformation To Point Pattern
rmhstart

Determine Initial State for Metropolis-Hastings Simulation.
humberside

Humberside Data on Childhood Leukaemia and Lymphoma
rescale.psp

Convert Line Segment Pattern to Another Unit of Length
lgcp.estK

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

Aherne's hamster tumour data
rshift.psp

Randomly Shift a Line Segment Pattern
alltypes

Calculate Statistic for All Types in a Multitype Point Pattern
residuals.ppm

Residuals for Fitted Point Process Model
DiggleGratton

Diggle-Gratton model
selfcrossing.psp

Crossing Points in a Line Segment Pattern
pppmatching.object

Class of Point Matchings
demopat

Artificial Data Point Pattern
letterR

Window in Shape of Letter R
localK

Neighbourhood density function
shift.ppp

Apply Vector Translation To Point Pattern
psp

Create a Line Segment Pattern
complement.owin

Take Complement of a Window
dirichlet.weights

Compute Quadrature Weights Based on Dirichlet Tessellation
distmap.ppp

Distance Map of Point Pattern
bdist.pixels

Distance to Boundary of Window
is.multitype.ppp

Test Whether A Point Pattern is Multitype
ppp

Create a Point Pattern
rotate

Rotate
union.quad

Union of Data and Dummy Points
pppdist

Distance Between Two Point Patterns
quadrat.test

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

The Spatstat Package
progressreport

Print Progress Reports
clickppp

Interactively Add Points
is.marked

Test Whether Marks Are Present
applynbd

Apply Function to Every Neighbourhood in a Point Pattern
rNeymanScott

Simulate Neyman-Scott Process
longleaf

Longleaf Pines Point Pattern
nndist.psp

Nearest neighbour distances between line segments
is.im

Test Whether An Object Is A Pixel Image
affine

Apply Affine Transformation
quad.object

Class of Quadrature Schemes
erode.owin

Erode a Window
rescale.owin

Convert Window to Another Unit of Length
rmhmodel

Define Point Process Model for Metropolis-Hastings Simulation.
Ord

Generic Ord Interaction model
rescue.rectangle

Convert Window Back To Rectangle
as.data.frame.ppp

Coerce Point Pattern to a Data Frame
plot.ppp

plot a Spatial Point Pattern
angles.psp

Orientation Angles of Line Segments
rshift

Random Shift
contour.im

Contour plot of pixel image
subset.im

Extract Subset of Image
crossing.psp

Crossing Points of Two Line Segment Patterns
as.ppp

Convert Data To Class ppp
predict.ppm

Prediction from a Fitted Point Process Model
swedishpines

Swedish Pines Point Pattern
MultiStrauss

The Multitype Strauss Point Process Model
print.psp

Print Brief Details of a Line Segment Pattern Dataset
trim.rectangle

Cut margins from rectangle
rotate.owin

Rotate a Window
japanesepines

Japanese Pines Point Pattern
summary.splitppp

Summary of a Split Point Pattern
eval.hyper

Evaluate an Expression in Each Row of a Hyperframe
rmhcontrol

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

Q-Q Plot of Residuals from Fitted Point Process Model
is.ppm

Test Whether An Object Is A Fitted Point Process Model
plot.im

Plot a Pixel Image
plot.splitppp

Plot a List of Point Patterns
fitin.ppm

Extract the Interaction from a Fitted Point Process Model
shift

Apply Vector Translation
unmark

Remove Marks from a Marked Point Pattern
endpoints.psp

Endpoints of Line Segment Pattern
shift.owin

Apply Vector Translation To Window
anova.ppm

ANOVA for Fitted Point Process Models
vertices

Vertices of a Window
setmarks

Set or Reset the Marks in a Point Pattern
unitname

Name for Unit of Length
vcov.ppm

Variance-Covariance Matrix for a Fitted Point Process Model
subset.fasp

Extract Subset of Function Array
rmhmodel.ppm

Interpret Fitted Model for Metropolis-Hastings Simulation.
rmhmodel.list

Define Point Process Model for Metropolis-Hastings Simulation.
clickpoly

Interactively Define a Polygon
crossdist.ppp

Pairwise distances between two different point patterns
Kest.fft

K-function using FFT
matchingdist

Distance for a Point Pattern Matching
dummy.ppm

Extract Dummy Points Used to Fit a Point Process Model
rotate.psp

Rotate a Line Segment Pattern
print.quad

Print a Quadrature Scheme
rthin

Random Thinning
shift.im

Apply Vector Translation To Pixel Image
subset.ppp

Extract or Replace Subset of Point Pattern
allstats

Calculate four standard summary functions of a point pattern.
bounding.box

Bounding Box of a Window or Point Pattern
scanpp

Read Point Pattern From Data File
is.subset.owin

Determine Whether One Window is Contained In Another
discretise

Safely Convert Point Pattern Window to Binary Mask
Jmulti

Marked J Function
suffstat

Sufficient Statistic of Point Process Model
rThomas

Simulate Thomas Process
fitted.ppm

Fitted Conditional Intensity for Point Process Model
unique.ppp

Extract Unique Points from a Spatial Point Pattern
finpines

Pine saplings in Finland.
rmpoint

Generate N Random Multitype Points
rmhmodel.default

Build Point Process Model for Metropolis-Hastings Simulation.
subset.splitppp

Extract or Replace Sub-Patterns
persp.im

Perspective Plot of Pixel Image
rshift.splitppp

Randomly Shift a List of Point Patterns
Pairwise

Generic Pairwise Interaction model
spruces

Spruces Point Pattern
cut.im

Convert Pixel Image from Numeric to Factor
spatstat-deprecated

Deprecated spatstat functions
Gmulti

Marked Nearest Neighbour Distance Function
append.psp

Combine Two Line Segment Patterns
is.marked.ppp

Test Whether A Point Pattern is Marked
residualspaper

Data and Code From JRSS Discussion Paper on Residuals
rpoint

Generate N Random Points
plot.psp

plot a Spatial Line Segment Pattern
plot.plotppm

Plot a plotppm Object Created by plot.ppm
profilepl

Profile Maximum Pseudolikelihood
data.ppm

Extract Original Data from a Fitted Point Process Model
diameter

Diameter of a Window
Softcore

The Soft Core Point Process Model
Strauss

The Strauss Point Process Model
update.ppm

Update a Fitted Point Process Model
fv.object

Data Frames of Function Values
bramblecanes

Hutchings' Bramble Canes data
chorley

Chorley-Ribble Cancer Data
subset.psp

Extract Subset of Line Segment Pattern
print.ppp

Print Brief Details of a Point Pattern Dataset
as.rectangle

Window Frame
subsetget.im

Reset Values in Subset of Image
distmap

Distance Map
owin.object

Class owin
nearest.raster.point

Find Pixel Nearest to a Given Point
raster.x

Cartesian Coordinates for a Pixel Raster
nnwhich

Nearest neighbour
envelope

Simulation envelopes of summary function
summary.owin

Summary of a Spatial Window
rstrat

Simulate Stratified Random Point Pattern
rMatClust

Simulate Matern Cluster Process
rescale.ppp

Convert Point Pattern to Another Unit of Length
shift.psp

Apply Vector Translation To Line Segment Pattern
subset.listof

Extract or Replace Subset of a List of Things
spokes

Spokes pattern of dummy points
nncross

Nearest Neighbour in Another Point Pattern
Kest

K-function
clarkevans

Clark and Evans Aggregation Index
logLik.ppm

Log Likelihood for Poisson Point Process Model
pcf.ppp

Pair Correlation Function of Point Pattern
nndist

Nearest neighbour distances
pairdist.psp

Pairwise distances between line segments
midpoints.psp

Midpoints of Line Segment Pattern
is.multitype

Test whether Object is Multitype
pcf.fv

Pair Correlation Function obtained from K Function
pairdist

Pairwise distances
plot.quad

plot a Spatial Quadrature Scheme
ppm

Fit Point Process Model to Data
affine.psp

Apply Affine Transformation To Line Segment Pattern
smooth.ppp

Spatial smoothing of observations at irregular points
runifpoint

Generate N Uniform Random Points
summary.ppm

Summarizing a Fitted Point Process Model
rescale

Convert dataset to another unit of length
runifdisc

Generate N Uniform Random Points in a Disc
square

Square Window
rotate.ppp

Rotate a Point Pattern
Kcross.inhom

Inhomogeneous Cross K Function
Kmulti

Marked K-Function
disc

Circular Window
im

Create a Pixel Image Object
identify.ppp

Identify Points in a Point Pattern
compatible.im

Test Whether Two Pixel Images Are Compatible
levelset

Level Set of a Pixel Image
ord.family

Ord Interaction Process Family
pairdist.default

Pairwise distances
reduced.sample

Reduced Sample Estimator using Histogram Data
gridcentres

Rectangular grid of points