points2network {shp2graph}R Documentation

Integrate a point data set into a network

Description

A function to integrate an individual point data set into a network under different rules (see details below).

Usage

points2network(ntdata,pointsxy,approach=1,ELComputed=FALSE,longlat=F,
               Detailed=F, ea.prop=NULL)

Arguments

ntdata

A “SpatialLinesDataFrame” or “SpatialLines” object

pointsxy

A two-column matrix of point coordinates (X, Y)

approach

specified by an integer ranging from 1 to 4 to define the approach for integration:

1: Mapping each point to the nearest node in the network/graph

2: Mapping each point to the nearest point (add them as nodes if they are not) on the network

3: Add a new edge(virtual edge) between each point and the nearest node

4: Add a new edge(virtual edge) between each point and the nearest point

ELComputed

If TRUE, the length of each edge will be calculated and returned

longlat

If TRUE, distances on an ellipse with WGS84 parameters will be returned

Detailed

If TRUE, all the vertices within the polylines of a spatial network will be recognised as nodes; if FALSE, only two endpoints of each polyline are treated as nodes

ea.prop

A vector (of the length equalling to the number of edge attributes in in the network “ntdata”) with values of 1 or 0:

1: the corresponding column in the data frame will be kept for the new network;

0: the corresponding column in the data frame will not be kept.

Value

A list consisted of:

nodelist

A “nodelist” object

edgelist

An “edgelist” object

CoorespondIDs

A vector of the cooresponding node ID for each point in “pointsxy”

nodexlist

A vector contains X-coordinates of all the nodes

nodeylist

A vector contains Y-coordinates of all the nodes

Eadf

A data frame of attributes of the returned edges, of which the structure is a data frame with [EdgeID,(attributes inherited from the input network data)]

VElist

A list of virtual edges if added, i.e. approaches 3 and 4 are used

Edgelength

If “ELComputed” is TRUE, lengths of all the edges will be returned as a numeric vector; otherwise it will be NULL.

Author(s)

Binbin Lu binbinlu@whu.edu.cn

See Also

ptsinnt.view

Examples

## Not run: 
data(ORN)
pts<-spsample(ORN.nt, 100, type="random")
ptsxy<-coordinates(pts)[,1:2]
ptsxy<-cbind(ptsxy[,1]+0.008,ptsxy[,2]+0.008)
#Mapping each point to the nearest node in the network/graph
res<-points2network(ntdata=ORN.nt,pointsxy=ptsxy, approach=1)
ptsinnt.view(ntdata=rn, nodelist=res[[1]], pointsxy=ptsxy,
             CoorespondIDs=res[[3]])
#Mapping each point to the nearest point (add them as nodes if they are not) on 
#the network
res<-points2network(ntdata=ORN.nt,pointsxy=ptsxy, approach=2,ea.prop=rep(0,37))
ptsinnt.view(ntdata=ORN.nt, nodelist=res[[1]], pointsxy=ptsxy, CoorespondIDs=res[[3]]) 
#Add a new edge(Virtual edge) between each point and the nearest node
res<-points2network(ntdata=ORN.nt,pointsxy=ptsxy, approach=3,ea.prop=rep(0,37))
VElist<-res[[7]]
ptsinnt.view(ntdata=ORN.nt, nodelist=res[[1]], pointsxy=ptsxy, CoorespondIDs=res[[3]], 
             VElist=VElist)
#Add a new edge(Virtual edge) between each point and the nearest point
res<-points2network(ntdata=ORN.nt,pointsxy=ptsxy, approach=4,ea.prop=rep(0,37))
VElist<-res[[7]]
ptsinnt.view(ntdata=ORN.nt, nodelist=res[[1]], pointsxy=ptsxy, CoorespondIDs=res[[3]],
             VElist=VElist) 

## End(Not run)

[Package shp2graph version 1-0 Index]