Learn R Programming

spatstat.linnet (version 3.2-2)

spatstat.linnet-package: The spatstat.linnet Package

Description

The spatstat.linnet package belongs to the spatstat family of packages. It contains the functionality for analysing spatial data on a linear network.

Arguments

Structure of the spatstat family

The orginal spatstat package grew to be very large. It has now been divided into several sub-packages:

  • spatstat.utils containing basic utilities

  • spatstat.sparse containing linear algebra utilities

  • spatstat.data containing datasets

  • spatstat.univar containing functions for estimating probability distributions of random variables

  • spatstat.geom containing geometrical objects and geometrical operations

  • spatstat.explore containing the main functionality for exploratory and non-parametric analysis of spatial data

  • spatstat.model containing the main functionality for statistical modelling and inference for spatial data

  • spatstat.linnet containing functions for spatial data on a linear network

  • spatstat, which simply loads the other sub-packages listed above, and provides documentation.

When you install spatstat, these sub-packages are also installed. Then if you load the spatstat package by typing library(spatstat), the other sub-packages listed above will automatically be loaded or imported. For an overview of all the functions available in these sub-packages, see the help file for spatstat in the spatstat package,

Additionally there are several extension packages:

  • spatstat.gui for interactive graphics

  • spatstat.local for local likelihood (including geographically weighted regression)

  • spatstat.Knet for additional, computationally efficient code for linear networks

  • spatstat.sphere (under development) for spatial data on a sphere, including spatial data on the earth's surface

The extension packages must be installed separately and loaded explicitly if needed. They also have separate documentation.

Overview of <span class="pkg">spatstat.linnet</span>

A linear network is a subset of the two-dimensional plane composed of straight line segments. It could represent a road network, for example. Our code requires that, if two segments intersect each other, then the intersection is a single point, and the intersection point is treated as a vertex of the network.

The spatstat.linnet package supports spatial data analysis on a linear network. The primary aim is to analyse spatial patterns of points on a network. The points could represent road accidents on a road network, for example.

The spatstat.linnet package provides code for handling

  • linear networks

  • point patterns on a linear network

  • pixel images on a linear network (where the network is divided into small segments and a numerical value is assigned to each segment)

  • functions on a linear network (i.e. functions that are defined at every location along the network)

  • tessellations of a linear network (where the network is subdivided into disjoint subsets with different labels)

  • point process models on a linear network

Here is a list of the main functionality provided in spatstat.linnet.

Linear networks

An object of class "linnet" represents a linear network. Examples of such objects include the dataset simplenet provided in the package.

Linear network objects can be created by the following functions:

linnetcreate a linear network
as.linnetconvert other data to a network
delaunayNetworknetwork of Delaunay triangulation
dirichletNetworknetwork of Dirichlet edges

Utilities for manipulating networks include:

[.linnetextract subset of linear network
clickjoininteractively join vertices in network
joinVerticesjoin existing vertices in a network
insertVerticesinsert new vertices at positions along network
addVerticesadd new vertices, extending a network
thinNetworkremove vertices or lines from a network
repairNetworkrepair internal format
vertices.linnetextract the vertices of network
terminalverticesfind terminal vertices of network
affine.linnetapply affine transformation
shift.linnetapply vector translation
rotate.linnetapply rotation
rescale.linnetrescale the unit of length
scalardilate.linnetphysically rescale the network
diameter.linnetdiameter of linear network
is.connected.linnetdetermine whether network is connected
lineardisccompute disc of given radius in network
marks.linnetextract marks of a network
marks<-.linnetassign marks to a network
plot.linnetplot a network
as.owin.linnetextract window containing network
as.psp.linnetextract line segments comprising network
nsegments.linnetnumber of segments in network
nvertices.linnetnumber of vertices in network
pixellate.linnetconvert network to 2D pixel image
print.linnetprint basic information
summary.linnetprint summary information
unitname.linnetextract name of unit of length
unitname<-.linnetassign name of unit of length
vertexdegreenumber of segments meeting each vertex
volume.linnettotal length of network
Window.linnetextract window containing network
density.linnetsmoothed 2D spatial density of lines

A network is called a tree if it has no closed loops. The following functions support the creation and manipulation of trees:

beginscheck start of character string
branchlabelfuntree branch membership labelling function
deletebranchdelete a branch of a tree
extractbranchextract a branch of a tree
treebranchlabelslabel vertices of a tree by branch membership
treepruneprune tree to given level

Point patterns on a linear network

An object of class "lpp" represents a point pattern on a linear network (for example, road accidents on a road network).

Examples of such objects include the following datasets provided in the spatstat.data package:

chicagoChicago crime data
dendriteDendritic spines data
spidersSpider webs on mortar lines of brick wall

There is also a dataset provided in the extension package spatstat.Knet:

wacrashesRoad accidents in Western Australia

Point patterns on a network can be created by the following functions:

lppcreate a point pattern on a linear network
as.lppconvert other data to point pattern on network
clicklppinteractively add points on a linear Network
crossing.linnetcrossing points between network and other lines

Point patterns on a network can be generated randomly using the following functions:

rpoislppPoisson points on linear network
runiflppuniform random points on a linear network
rlpprandom points on a linear network
rSwitzerlppsimulate Switzer-type point process on linear network
rThomaslppsimulate Thomas process on linear network
rcelllppsimulate cell process on linear network
rjitter.lpprandomly perturb a point pattern on a network

Functions for manipulating a point pattern on a network include the following. An object of class "lpp" also belongs to the class "ppx", for which additional support is available.

as.ppp.lppconvert to 2D point pattern
as.psp.lppextract line segments
marks.ppxextract marks associated with points
marks<-.ppxassign marks to points on network
nsegments.lppcount number of segments
print.lppprint basic information
summary.lppprint summary information
unitname.lppextract name of unit of length
unitname<-.lppassign name of unit of length
unmark.lppremove marks
subset.lppsubset of points satisfying a condition
[.lppextract subset of point pattern
Window.lppextract window containing network
as.owin.lppextract window containing network
affine.lppapply affine transformation
shift.lppapply vector translation
rotate.lppapply rotation
rescale.lpprescale the unit of length
scalardilate.lppphysically rescale the network and points
connected.lppfind connected components of point pattern on network
cut.lppclassify points in a Point Pattern on a Network
distfun.lppdistance map (function)
distmap.lppdistance map (image)
domain.lppextract the linear network
identify.lppinteractively identify points
is.multitype.lpprecognize whether point pattern is multitype
nncross.lppnearest neighbours
nndist.lppnearest neighbour distances
nnfromvertexnearest data point from each vertex
nnfun.lppnearest neighbour map
nnwhich.lppidentify nearest neighbours
pairdist.lpppairwise shortest-path distances
plot.lppplot point pattern on linear Network
points.lppdraw points on existing plot
superimpose.lppsuperimpose several point patterns
text.lppadd text labels
unstack.lppseparate multiple columns of marks

Pixel images on a network

An object of class "linim" represents a pixel image on a linear network. Effectively, the network is divided into small segments (lixels) and each small segment is assigned a value, which could be numeric, factor, logical or complex values.

Pixel images on a network can be created using the following functions:

linimcreate pixel image on linear network
as.linimconvert other data to pixel image on network

Functions for manipulating a pixel image on a network include:

[.linimextract subset of pixel image on linear network
[<-.linimreset values in subset of image on linear network
Math.linimS3 group generic methods for images on a linear network
eval.linimevaluate expression involving pixel images on linear network
as.linnet.linimextract linear network
integral.linimintegral of pixel image on a linear network
mean.linimmean of pixel values
median.linimmedian of pixel values
quantile.linimquantiles of pixel values
as.data.frame.linimconvert to data frame
print.linimprint basic information
summary.linimprint summary information
affine.linimapply affine transformation
scalardilate.linimapply scalar dilation
shift.linimapply vector translation
pairs.linimscatterplot matrix for images
persp.linimperspective view of pixel image on network
plot.linimplot pixel image on linear network

Functions on a linear network

An object of class "linfun" represents a function defined at any location along the network. Objects of this class are created by the following functions:

linfuncreate function on a linear network
as.linfunconvert other data to function on network

The following supporting code is available:

print.linfunprint basic information
summary.linfunprint summary information
plot.linfunplot function on network
persp.linfunperspective view of function on network
as.data.frame.linfunconvert to data frame
as.owin.linfunextract window containing network
as.function.linfunconvert to ordinary R function

Tessellations of a linear network

An object of class "lintess" represents a tessellation of the network, that is, a subdivision of the network into disjoint subsets called ‘tiles’. Objects of this class are created by the following functions:

lintesscreate tessellation of network
chop.linnetdivide a linear network into tiles using infinite lines
divide.linnetdivide linear network at cut points
lineardirichletDirichlet tessellation on a linear network

The following functions are provided for manipulating a tessellation on a network:

as.data.frame.lintessconvert to data frame
intersect.lintessintersection of two tessellations on network
lineartileindexdetermine which tile contains each given point on network
marks.lintessextract marks of each tile
marks<-.lintessassign marks to each tile
plot.lintessplot tessellation on network
tile.lengthscompute lengths of tiles
tilenames.lintessnames of tiles
as.linfun.lintessconvert tessellation to a function

Smoothing a point pattern on a linear network:

Given a point pattern dataset on a linear network, it is often desired to estimate the spatially-varying density or intensity of points along the network. For example if the points represent road accidents, then we may wish to estimate the spatially-varying density of accidents per unit length (over a given period of time).

Related tasks include estimation of relative risk, and smoothing of of values observed at the data points.

density.lppkernel estimate of intensity
densityEqualSplitkernel estimate of intensity using equal-split algorithm
densityHeat.lppkernel estimate of intensity using heat equation
densityQuick.lppkernel estimate of intensity using a 2D kernel
densityVoronoi.lppintensity estimate using Voronoi-Dirichlet Tessellation
densityfun.lppkernel estimate of intensity as a function
bw.lpplBandwidth selection for kernel estimate of intensity
bw.voronoibandwidth selection for Voronoi estimator
relrisk.lppkernel estimate of relative risk
bw.relrisk.lppBandwidth selection for relative risk
Smooth.lppspatial smoothing of observations at points

Exploration of dependence on a covariate:

Another task is to investigate how the spatially-varying intensity of points depends on an explanatory variable (covariate). The covariate may be given as a pixel image on the network (class "linim") or as a function on the network (class "linfun").

rhohat.lppnonparametric estimate of intensity as function of a covariate
roc.lppReceiver Operating Characteristic for data on a network
auc.lppArea Under ROC Curve for data on a network
cdf.test.lppspatial distribution test for points on a linear network
berman.test.lppBerman's tests for point pattern on a network
sdr.lppSufficient Dimension Reduction for a point pattern on a linear network

Summary statistics for a point pattern on a linear network:

These are for point patterns on a linear network (class lpp). For unmarked patterns:

linearK\(K\) function on linear network
linearKinhominhomogeneous \(K\) function on linear network
linearpcfpair correlation function on linear network
linearpcfinhominhomogeneous pair correlation on linear network
linearJinhominhomogeneous \(J\) function on linear network
linearKEuclid\(K\) function on linear network using Euclidean distance
linearKEuclidInhominhomogeneous \(K\) function on linear network using Euclidean distance
linearpcfEuclidpair correlation function on linear network using Euclidean distance
linearpcfEuclidInhominhomogeneous pair correlation on linear network using Euclidean distance

For multitype patterns:

linearKcross\(K\) function between two types of points
linearKdot\(K\) function from one type to any type
linearKcross.inhomInhomogeneous version of linearKcross
linearKdot.inhomInhomogeneous version of linearKdot
linearmarkconnectMark connection function on linear network
linearmarkequalMark equality function on linear network
linearpcfcrossPair correlation between two types of points
linearpcfdotPair correlation from one type to any type
linearpcfcross.inhomInhomogeneous version of linearpcfcross
linearpcfdot.inhomInhomogeneous version of linearpcfdot

Related facilities:

pairdist.lppdistances between pairs
crossdist.lppdistances between pairs
nndist.lppnearest neighbour distances
nncross.lppnearest neighbour distances
nnwhich.lppfind nearest neighbours
nnfun.lppfind nearest data point
density.lppkernel smoothing estimator of intensity
distfun.lppdistance transform
envelope.lppsimulation envelopes
rpoislppsimulate Poisson points on linear network
runiflppsimulate random points on a linear network

It is also possible to fit point process models to lpp objects.

Point process models on a linear network:

An object of class "lpp" represents a pattern of points on a linear network. Point process models can also be fitted to these objects. Currently only Poisson models can be fitted.

lppmpoint process model on linear network
anova.lppmanalysis of deviance for
point process model on linear network
envelope.lppmsimulation envelopes for
point process model on linear network
fitted.lppmfitted intensity values
predict.lppmmodel prediction on linear network
data.lppmextract original data
berman.test.lppmBerman's tests of goodness-of-fit
is.marked.lppmRecognise whether model is marked
is.multitype.lppmRecognise whether model is multitype
is.stationary.lppmRecognise whether model is stationary
model.frame.lppmExtract the variables in model
model.images.lppmCompute images of constructed covariates
model.matrix.lppmExtract design matrix
plot.lppmPlot fitted point process model
pseudoR2.lppmCalculate Pseudo-R-Squared for model
simulate.lppmsimulate fitted point process model

Licence

This library and its documentation are usable under the terms of the "GNU General Public License", a copy of which is distributed with the package.

Author

Adrian Baddeley Adrian.Baddeley@curtin.edu.au, Rolf Turner rolfturner@posteo.net and Ege Rubak rubak@math.aau.dk.

Acknowledgements

Ottmar Cronie, Tilman Davies, Greg McSwiggan and Suman Rakshit made substantial contributions of code.

Details

spatstat is a family of R packages for the statistical analysis of spatial data. Its main focus is the analysis of spatial patterns of points in two-dimensional space.

The original spatstat package has now been split into several sub-packages.

This sub-package spatstat.linnet contains the user-level functions from spatstat that are concerned with spatial data on a linear network.