Title: | Convert a 'SpatialLinesDataFrame' -Class Object to an 'igraph'-Class Object |
---|---|
Description: | Functions for converting and processing network data from a 'SpatialLinesDataFrame' -Class object to an 'igraph'-Class object. |
Authors: | Binbin Lu |
Maintainer: | Binbin Lu <[email protected]> |
License: | GPL (>= 2) |
Version: | 1-0 |
Built: | 2025-02-01 03:11:29 UTC |
Source: | https://github.com/cran/shp2graph |
A function that returns degrees of nodes from provided “nodelist” and “edgelist”; while in-degrees and out-degrees are returned if edges are directed).
Degree.list(nodelist, edgelist, Directed=F)
Degree.list(nodelist, edgelist, Directed=F)
nodelist |
A “nodelist” object |
edgelist |
An “edgelist” object |
Directed |
TRUE if edges are directed; FALSE, otherwise |
Lists of different contents are returned for undirected and directed edges respectively: For undirected graph:
DegreeL |
An integer vector of degrees for each node in the given “nodelist” |
For directed type:
InDegreeL |
An integer vector of In-degrees for each node in the given “nodelist” |
OutDegreeL |
An integer vector of Out-degrees for each node in the given “nodelist” |
This function returns differently for undirected and directed networks, where both In-degrees and Out-degrees are calculated for a directed network, and only degrees are returned for an undirected networks.
Binbin Lu [email protected]
A function to orientate each edge according to the given vector.
Directed(edgelist, direction.v=rep(0,length(edgelist[,1])), eadf=NULL)
Directed(edgelist, direction.v=rep(0,length(edgelist[,1])), eadf=NULL)
edgelist |
An “edgelist” object |
direction.v |
A vector (of the length equalling to the number of edges in the given “edgelist”) with values of 1 (TRUE) or 0 (FALSE), 1 (TRUE) indicates a directed (one-way) edge, while 0 (FALSE) means an undirected (double-way) edge |
eadf |
A data frame of attributes corresponding to all the edges; |
Within a road network, some road segments might be one-way while the rest are double-way. This suitation makes it complex to define directed or undirected edges in a graph. This function is to orientate each edge according to the given vector, “direction.v”: 1 (TRUE) indicates one-way, while 0 (FALSE) represents double-way. All the double-way (undirected) edges in the given “edgelist” are redefined as two directed edges (e.g. a double-way (undirected) edge(nid1, nid2) is redefined as two one-way (directed) edges, (nid1, nid2) and (nid2, nid1)). The one-way (directed) edges are left in their directed forms. In other words, all the edges returned by this function will be directed, and used to be construct a directed graph.
A list consisted of:
newEdgelist |
An “edgelist” object with directed edges |
newEadf |
A data frame of attributes for the new “edgelist” |
Binbin Lu [email protected]
“edgelist” is an interchange structure of edges from a spatial network into an “igraph” object. It is a three-column matrix, of which each row is designed as [EdgeID,NodeID(from),NodeID(to)].
Both “nodelist” and “edgelist” are interchange structures of nodes and edges extracted from a spatial network in a “SpatialLines” or “SpatialLinesDataFrame” object. They are always concerned together, and returned by the function readshpnw as initial results for the following steps.
If the parameter “Detailed” specified in readshpnw is TRUE, all the endpoints of polyines will be extracted as nodes, then the converted graph will have the same spatial details with the transformed “SpatialLines” or “SpatialLinesDataFrame” object. To retrieve the original attributes in the “SpatialLinesDataFrame” object, the original edge ID is also kept and the row structure will be [EdgeID,eid,NodeID(from),NodeID(to)], in which EdgeID refers to the new edge id while eid represents the original edge ID.
Binbin Lu [email protected]
This data set is a part of Estevan road network downloaded from OpenStreetMap, and a version with topology errors corrected is also incorporated.
data(ERN_OSM) data(ERN_OSM_correct)
data(ERN_OSM) data(ERN_OSM_correct)
Two “SpatialLinesDataFrame” objects named “ERN_OSM.nt” and “ERN_OSM_cor.nt”.
https://www.openstreetmap.org/#map=14/49.1388/-102.9961
OpenStreetMap. 2014. Estevan road network. ed. O. community.
This data set is sampled from a house price data set provided by the Nationwide Building Society of the UK, and combined with various hedonic variables.
data(LNHP)
data(LNHP)
A “SpatialPointsDataFrame” object named “LN.prop”.
In this data set, attributes are interpreted as follows:
PURCHASE: sale price in GBP
FLOORSZ: floor size of the property in square metres;
BATH2: 1 if the property has 2 or more bathrooms, 0 otherwise;
BEDS2: 1 if the property has 2 or more bedrooms, 0 otherwise;
CENTHEAT: 1 if the property has central heating, 0 otherwise;
GARAGE1: 1 if the property has one or more garages, 0 otherwise;
BLDPWW1: 1 if the property was built prior to 1914, 0 otherwise;
BLDINTW: is 1 if the property was built between 1914 and 1939, 0 otherwise;
BLD60S: 1 if the property was built between 1960 and 1969, 0 otherwise;
BLD70S: 1 if the property was built between 1970 and 1979, 0 otherwise;
BLD80S: 1 if the property was built between 1980 and 1989, 0 otherwise;
BLD90S: 1 if the property was built between 1990 and 2000, 0 otherwise;
TYPEDETCH: 1 if the property is detached (i.e. it is stand-alone), 0 otherwise;
TYPETRRD: 1 if the property is in a terrace of similar houses, 0 otherwise;
TYPEFLAT: 1 if the property is a flat or apartment, 0 otherwise;
PROF: percentage of the workforce in professional or managerial occupations in the census enumeration district in which the house is located.
UNEMPLOY: percentage of unemployment in the census enumeration district in which the house is located.
X: X coordinate.
Y: Y coordinat.
Lu, B., M. Charlton, P. Harris & A. S. Fotheringham (2014) Geographically weighted regression with a non-Euclidean distance metric: a case study using hedonic house price data. International Journal of Geographical Information Science, 28, 660-681.
The London Road network data set is produced by the UK Ordnance Survey (OS) in 2001.
data(LNNT)
data(LNNT)
A “SpatialLinesDataFrame” object named “LN.nt”.
In this data set, roads are categorized into four types (nt_RoadTyp):
Mo: motorway
a: A-road
b: B-road
Mi: minor road
Speed limit for each road segment is also incoporated in the attribute “Speed” (Transport for London, 2011)
Lu, B., M. Charlton, P. Harris & A. S. Fotheringham (2014) Geographically weighted regression with a non-Euclidean distance metric: a case study using hedonic house price data. International Journal of Geographical Information Science, 28, 660-681.
Transport for London, (2011) Intelligent Speed Adaptation [online]. http://www.tfl.gov.uk/corporate/projectsandschemes/7893.aspx#For_developers. Available from: http://www.tfl.gov.uk/corporate/projectsandschemes/7893.aspx#For_developers.
A function to simplfy multiple-edge into one representative edge, where a multiple-edge structure refers to a set of edges sharing with the same pair of nodes.
ME.simplification(nodelist, edgelist, eadf=NULL, ea.prop=NULL, Directed=F, DegreeL=NULL, InDegreeL=NULL, OutDegreeL=NULL,Nexception=NULL, Eexception=NULL)
ME.simplification(nodelist, edgelist, eadf=NULL, ea.prop=NULL, Directed=F, DegreeL=NULL, InDegreeL=NULL, OutDegreeL=NULL,Nexception=NULL, Eexception=NULL)
nodelist |
A “nodelist” object; |
edgelist |
An “edgelist” object |
eadf |
A data frame of attributes corresponding to all the edges; |
ea.prop |
A vector (of the length equalling to the number of edge attributes in “eadf”) with values of 1, 2, 3 or 4, and each specific value represent a function to assign the attributes of the edited edges, see also Redef.functions: 1->sum(v) 2->min(v) 3->max(v) 4->mean(v) |
Directed |
TRUE if edges are directed, FALSE otherwise; |
DegreeL |
An integer vector of degrees for each node in the given “nodelist”, and it could be ignored if edges are directed |
InDegreeL |
An integer vector of In-degrees for each node in the given “nodelist”, and it could be ignored if edges are undirected |
OutDegreeL |
An integer vector of Out-degrees for each node in the given “nodelist”, and it could be ignored if edges are undirected |
Nexception |
A vector of node IDs concerned as exceptions, and all the edges with these nodes included won't be processed; |
Eexception |
A vector of edge IDs concerned as exceptions, and all these edges won't be processed; |
Two types of list returned for undirected and directed edges, respectively:
For “undirected” edges:
newNodelist |
New node list with multiple-edges simplified; |
newEdgelist |
New edge list with multiple-edges simplified; |
newEadf |
New attribute data frame for the returned edgelist; |
DegreeL |
New degree vector cooresponding to the newly returned node list; |
For “directed” network:
newNodelist |
New node list with multiple-edges simplified; |
newEdgelist |
New edgelist with multiple-edges simplified; |
newEadf |
Data frame of attributes for the newly returned edge list; |
InDegreeL |
New In-degree vector cooresponding to the newly returned node list; |
OutDegreeL |
New Out-degree vector cooresponding to the newly returned node list; |
Edges are recognised as a structure of multiple-edge when they share the same pair of nodes. Note that the order of the nodes should be also the same when edges are directed.
Binbin Lu [email protected]
SL.extraction
, PN.amalgamation
A function to produce an “igraph” object with the “nodelist” and “edgelist”, which could be returned by the function readshpnw.
nel2igraph(nodelist, edgelist, weight = NULL, eadf = NULL, Directed = FALSE)
nel2igraph(nodelist, edgelist, weight = NULL, eadf = NULL, Directed = FALSE)
nodelist |
A “nodelist” object |
edgelist |
An “edgelist” object |
weight |
A numberic vector to weight all the edges in the “edgelist”, of which the length equals to the number of edges; |
eadf |
A data frame of attributes corresponding to all the edges; |
Directed |
TRUE if edges are directed, FALSE otherwise; |
1. The weighting vector, “weight”, will be used as default for any weigted calculations with edges in the “igraph” object.
2. The coordinate of each node is attached as attributes “X” and “Y”,
which could be retrived via the function “get.vertex.attribute
” from
the package igraph.
gr |
An “igraph” object |
Binbin Lu [email protected]
data(ORN) rtNEL<-readshpnw(ORN.nt, ELComputed=TRUE) #Add the edge length as the weight for graph igr<-nel2igraph(rtNEL[[2]],rtNEL[[3]],weight=rtNEL[[4]]) plot(igr, vertex.label=NA, vertex.size=2,vertex.size2=2) #plot(ORN.nt)
data(ORN) rtNEL<-readshpnw(ORN.nt, ELComputed=TRUE) #Add the edge length as the weight for graph igr<-nel2igraph(rtNEL[[2]],rtNEL[[3]],weight=rtNEL[[4]]) plot(igr, vertex.label=NA, vertex.size=2,vertex.size2=2) #plot(ORN.nt)
“nodelist” is an interchange structure of nodes from a spatial network into an “igraph” object. It is a two-column data frame, of which each row is designed as [NodeID,coordinate(X,Y)].
Both “nodelist” and “edgelist” are interchange structures of nodes and edges extracted from a spatial network in a “SpatialLines” or “SpatialLinesDataFrame” object. They are always concerned together, and returned by the function readshpnw as initial results for the following steps.
Binbin Lu [email protected]
A function that returns the coordinates of nodes in a two-column matrix (X,Y) from a “nodelist”
Nodes.coordinates(nodelist)
Nodes.coordinates(nodelist)
nodelist |
A “nodelist” object |
Nodesxy |
A two-column matrix (X, Y) |
Binbin Lu [email protected]
A function to check the connectivity of a given network.
nt.connect(nt)
nt.connect(nt)
nt |
A “SpatialLines” or “SpatialLinesDataFrame” object. |
In this function, all the nodes are traversed, and classified dynamically via a rule, that any pair of different nodes fall into a same category if they could be reached from each other. A map will be plotted spontaneously with differet categories (i.e. self-connected parts) in distinct colors. Finally, the self-connected part with the most nodes will be returned as a new “SpatialLinesDataFrame” object.
Binbin Lu [email protected]
This data set is a part of Ontario road network data set downloaded from Ontario Ministry of Natural Resources.
data(ORN)
data(ORN)
A “SpatialLinesDataFrame” object named “ORN.nt”.
https://www.geographynetwork.ca/website/orn/viewer.htm
Peterborough, ON: Ontario Ministry of Natural Resources, Ontario Road Network. Available: https://www.geographynetwork.ca/website/orn/viewer.htm, 2006, (Accessed Dec. 4, 2009)
A function to amalgamate edges connected by a pseudo-node.
PN.amalgamation(nodelist, edgelist, eadf=NULL, ea.prop=NULL, Directed=F, DegreeL=NULL, InDegreeL=NULL, OutDegreeL=NULL,Nexception=NULL, Eexception=NULL)
PN.amalgamation(nodelist, edgelist, eadf=NULL, ea.prop=NULL, Directed=F, DegreeL=NULL, InDegreeL=NULL, OutDegreeL=NULL,Nexception=NULL, Eexception=NULL)
nodelist |
A “nodelist” object; |
edgelist |
An “edgelist” object |
eadf |
A data frame of attributes corresponding to all the edges; |
ea.prop |
A vector (of the length equalling to the number of edge attributes in “eadf”) with values of 1, 2, 3 or 4, and each specific value represent a function to assign the attributes of the edited edges, see also Redef.functions: 1->sum(v) 2->min(v) 3->max(v) 4->mean(v) |
Directed |
TRUE if edges are directed, FALSE otherwise; |
DegreeL |
An integer vector of degrees for each node in the given “nodelist”, and it could be ignored if edges are directed |
InDegreeL |
An integer vector of In-degrees for each node in the given “nodelist”, and it could be ignored if edges are undirected |
OutDegreeL |
An integer vector of Out-degrees for each node in the given “nodelist”, and it could be ignored if edges are undirected |
Nexception |
A vector of node IDs concerned as exceptions, and all the edges with these nodes included won't be processed; |
Eexception |
A vector of edge IDs concerned as exceptions, and all these edges won't be processed; |
Two types of list returned for undirected and directed edges, respectively:
For “undirected” edges:
newNodelist |
New node list with pseudo-nodes removed; |
newEdgelist |
New edge list with pseudo-nodes removed; |
newEadf |
New attribute data frame for the returned edgelist; |
DegreeL |
New degree vector cooresponding to the newly returned node list; |
For “directed” network:
newNodelist |
New node list with pseudo-nodes removed; |
newEdgelist |
New edgelist with pseudo-nodes removed; |
newEadf |
Data frame of attributes for the newly returned edge list; |
InDegreeL |
New In-degree vector cooresponding to the newly returned node list; |
OutDegreeL |
New Out-degree vector cooresponding to the newly returned node list; |
Node in a directed network is recognised a a pseudo-node with in-degree and out-degree equalling to 1; while it could be a pseudo-node with degree equalling to 2 in a undirected network.
Binbin Lu [email protected]
SL.extraction
, ME.simplification
data(ORN) rtNEL<-readshpnw(ORN.nt, ELComputed=TRUE) res.sl<-SL.extraction(rtNEL[[2]],rtNEL[[3]]) res.me<-ME.simplification(res.sl[[1]],res.sl[[2]],DegreeL=res.sl[[4]]) res.pn<-PN.amalgamation(res.me[[1]],res.me[[2]],DegreeL=res.me[[4]]) ptcoords<-Nodes.coordinates(res.pn[[1]]) #plot(ORN.nt) #points(ptcoords, col="green") #plot(ORN.nt) #points(Nodes.coordinates(rtNEL[[2]]), col="red")
data(ORN) rtNEL<-readshpnw(ORN.nt, ELComputed=TRUE) res.sl<-SL.extraction(rtNEL[[2]],rtNEL[[3]]) res.me<-ME.simplification(res.sl[[1]],res.sl[[2]],DegreeL=res.sl[[4]]) res.pn<-PN.amalgamation(res.me[[1]],res.me[[2]],DegreeL=res.me[[4]]) ptcoords<-Nodes.coordinates(res.pn[[1]]) #plot(ORN.nt) #points(ptcoords, col="green") #plot(ORN.nt) #points(Nodes.coordinates(rtNEL[[2]]), col="red")
A function to integrate an individual point data set into a network under different rules (see details below).
points2network(ntdata,pointsxy,approach=1,ELComputed=FALSE,longlat=F, Detailed=F, ea.prop=NULL)
points2network(ntdata,pointsxy,approach=1,ELComputed=FALSE,longlat=F, Detailed=F, ea.prop=NULL)
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. |
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. |
Binbin Lu [email protected]
## 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)
## 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)
A specific function to visualizethe integration between a point data set and spatila
network, i.e. results returned by the function points2network
ptsinnt.view(ntdata, nodelist, pointsxy, CoorespondIDs, VElist=NULL)
ptsinnt.view(ntdata, nodelist, pointsxy, CoorespondIDs, VElist=NULL)
ntdata |
A “SpatialLinesDataFrame” or “SpatialLines” object |
nodelist |
A “nodelist” object |
pointsxy |
A two-column matrix of point coordinates (X, Y) |
CoorespondIDs |
A vector of the cooresponding node ID for each point in “pointsxy” |
VElist |
A list of virtual edges if added, i.e. approaches 3 and 4 are used |
Binbin Lu [email protected]
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, mapping.method=1) #Visualize the results without virtual edges #ptsinnt.view(ntdata=ORN.nt, nodelist=res[[1]], pointsxy=ptsxy, # CoorespondIDs=res[[3]]) #Visualize the results with virtual edges #res<-points2network(ntdata=ORN.nt,pointsxy=ptsxy, mapping.method=3, # ea.prop=rep(0,37)) #VElist<-res[[7]] #ptsinnt.view(ntdata=ORN.nt, nodelist=res[[1]], pointsxy=ptsxy, # CoorespondIDs=res[[3]], VElist=VElist)
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, mapping.method=1) #Visualize the results without virtual edges #ptsinnt.view(ntdata=ORN.nt, nodelist=res[[1]], pointsxy=ptsxy, # CoorespondIDs=res[[3]]) #Visualize the results with virtual edges #res<-points2network(ntdata=ORN.nt,pointsxy=ptsxy, mapping.method=3, # ea.prop=rep(0,37)) #VElist<-res[[7]] #ptsinnt.view(ntdata=ORN.nt, nodelist=res[[1]], pointsxy=ptsxy, # CoorespondIDs=res[[3]], VElist=VElist)
A function to read a spatial network from a “SpatialLines” or “SpatialLinesDataFrame” object, and resolve it into a “nodelist” and “edgelist” for the following conversion.
readshpnw(ntdata, ELComputed=FALSE, longlat=FALSE, Detailed=FALSE, ea.prop=NULL)
readshpnw(ntdata, ELComputed=FALSE, longlat=FALSE, Detailed=FALSE, ea.prop=NULL)
ntdata |
A “SpatialLinesDataFrame” or “SpatialLines” object |
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. |
This function plays the first step to convert a spatial network (in a “SpatialLines” or “SpatialLinesDataFrame” object) into an “igraph” object by returning a “nodelist” and “edgelist”.
A list consisted of:
Detailed |
TRUE if the output is under a “Detailed” mode; |
nodelist |
A “nodelist” object |
edgelist |
An “edgelist” object |
Edgelength |
If “ELComputed” is TRUE, lengths of all the edges will be returned as a numeric vector; otherwise it will be NULL. |
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)] |
nodexlist |
A vector contains X-coordinates of all the nodes |
nodeylist |
A vector contains Y-coordinates of all the nodes |
Binbin Lu [email protected]
data(ORN) rtNEL<-readshpnw(ORN.nt) nl<-rtNEL[[2]] el<-rtNEL[[3]] #Compute edge length rtNEL<-readshpnw(ORN.nt, ELComputed=TRUE) edgelength<-rtNEL[[4]] eadf<-rtNEL[[5]]
data(ORN) rtNEL<-readshpnw(ORN.nt) nl<-rtNEL[[2]] el<-rtNEL[[3]] #Compute edge length rtNEL<-readshpnw(ORN.nt, ELComputed=TRUE) edgelength<-rtNEL[[4]] eadf<-rtNEL[[5]]
A function to provide a collection of functions to redefine attributes of edited edges in the functions PN.amalgamation and ME.simplification.
Redef.functions(v, typ=1)
Redef.functions(v, typ=1)
v |
An input vector for the specified function; |
typ |
A value equalling to 1, 2, 3 or 4 to specify a redefinition function: 1->sum(v) 2->min(v) 3->max(v) 4->mean(v) |
It is easy to include more specific methods for attribute redefinition via incorporating the corresponding functions. In other words, you can define more methods by numbering them with 5, 6, etc.
Binbin Lu [email protected]
A function to extract self-loops away in given network.
SL.extraction(nodelist, edgelist, eadf=NULL,Directed=F, DegreeL=NULL, InDegreeL=NULL, OutDegreeL=NULL,Nexception=NULL,Eexception=NULL)
SL.extraction(nodelist, edgelist, eadf=NULL,Directed=F, DegreeL=NULL, InDegreeL=NULL, OutDegreeL=NULL,Nexception=NULL,Eexception=NULL)
nodelist |
A “nodelist” object; |
edgelist |
An “edgelist” object |
eadf |
A data frame of attributes corresponding to all the edges; |
Directed |
TRUE if edges are directed, FALSE otherwise; |
DegreeL |
An integer vector of degrees for each node in the given “nodelist”, and it could be ignored if edges are directed |
InDegreeL |
An integer vector of In-degrees for each node in the given “nodelist”, and it could be ignored if edges are undirected |
OutDegreeL |
An integer vector of Out-degrees for each node in the given “nodelist”, and it could be ignored if edges are undirected |
Nexception |
A vector of node IDs concerned as exceptions, and all the edges with these nodes included won't be processed; |
Eexception |
A vector of edge IDs concerned as exceptions, and all these edges won't be processed; |
Two types of list returned for undirected and directed edges, respectively:
For “undirected” edges:
newNodelist |
New node list with self-loops removed; |
newEdgelist |
New edge list with self-loops removed; |
newEadf |
New attribute data frame for the returned edgelist; |
DegreeL |
New degree vector cooresponding to the newly returned node list; |
For “directed” network:
newNodelist |
New node list with self-loops removed; |
newEdgelist |
New edgelist with self-loops removed; |
newEadf |
Data frame of attributes for the newly returned edge list; |
InDegreeL |
New In-degree vector cooresponding to the newly returned node list; |
OutDegreeL |
New Out-degree vector cooresponding to the newly returned node list; |
An edge is recognised as a structure of self-loop when it starts and ends at the same point (location).
Binbin Lu [email protected]
PN.amalgamation
, ME.simplification