converting a spatial network to a graph converting a spatial network

23
Converting a spatial network to a graph Converting a spatial network to a graph in R Binbin Lu, Martin Charlton National Centre for Geocomputation National University of Ireland Maynooth Maynooth, Co.Kildare, Ireland Maynooth, Co.Kildare, Ireland The R User Conference 2011

Upload: dangliem

Post on 02-Jan-2017

244 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Converting a spatial network to a graph Converting a spatial network

Converting a spatial network to a graphConverting a spatial network to a graph in R

Binbin Lu, Martin CharltonNational Centre for Geocomputation

National University of Ireland Maynooth

Maynooth, Co.Kildare, IrelandMaynooth, Co.Kildare, Ireland

The R User Conference 2011

Page 2: Converting a spatial network to a graph Converting a spatial network

ContentsContents

Motivation

Key points in the conversionKey points in the conversion

R package “shp2graph”

Future work

Page 3: Converting a spatial network to a graph Converting a spatial network

MotivationMotivation How should I get all theh t t th b tshortest paths between

any pair of points?

SANNETSANNET

pgRouting……

Coding with Dijkstra algorithmg

ButI am an R user andI am an R user andI am “lazy”

Page 4: Converting a spatial network to a graph Converting a spatial network

Search in R packagesSearch in R packages…sp between()RBGLgraphmaptools sp.between()

shortest.paths()

RBGLgraph

igraphShape file

maptools

sp

Solution: Converting a spatial network to a graph object

Key points for this conversion:Key points for this conversion:Modelling Road network with graph data model

Attribute heritageg

Topology

Structure optimization

Integration of points into network

Page 5: Converting a spatial network to a graph Converting a spatial network

Graph data modelGraph data modelEdge (Arc) Node (Vertex)g ( ) ( )

Node listEdge list

ID X Y …NodeID1 NodeID2 …

Matrix

Graph data model:

A kind of data model to abstract away

1ID 2ID nID1ID

ID0 1or

... geographical details and represent a

network as a graph, that is, as a finite

2ID

nID

ija Edgelength ......

set of points called nodes (i.e. vertices)

and relations between these points

ll d d (i )n called edges (i.e. arcs).

Page 6: Converting a spatial network to a graph Converting a spatial network

Attributes inheritance and translationAttributes inheritance and translation

• Geometry Spatial coordinates of nodes 

• Attributes IDs of nodes and edges; IDs of nodes and edges;

Lengths of edges;

Orientation of edges Orientation of edges

……

Page 7: Converting a spatial network to a graph Converting a spatial network

Topology errors

(a) Dangling arc (b) Undershoot

(c) Overshoot (d) Missing intersection

Page 8: Converting a spatial network to a graph Converting a spatial network

Connectivity ProblemConnectivity Problem

Page 9: Converting a spatial network to a graph Converting a spatial network

Solutions to correct topology errorsSolutions to correct topology errors

GIS software Topology correction tools/functions

ArcGIS  Extend Polyline Tool, Intersect Polylines Tool, Remove Redundant NodesTool and Clean Dangles Tool in ET Geo‐toolsClean Polyline, Clean Dangling Nodes, Split Polylines(With a Layer) in ETGeo Wizards

ArcInfo Clean {Coverage}, Validate Entire Topology tool, Fix Topology Error tool

l i l i l l b k d lGRASS Cleaning tools in v.clean Toolset: break, rmdangle, snap

AutoCAD Map Creating a network topology, Editing Topologies

Page 10: Converting a spatial network to a graph Converting a spatial network

Over correction

Page 11: Converting a spatial network to a graph Converting a spatial network

Structure OptimizationStructure Optimization

43

2

1 2

10 98

12

14

1113

15

16

8

5 617 18 7

Pseudo-node

Multiple-edgeSelf-loop

Page 12: Converting a spatial network to a graph Converting a spatial network

Test on Ontario Road Network dataTest on Ontario Road Network data

Page 13: Converting a spatial network to a graph Converting a spatial network

Test on Ontario Road Network dataTest on Ontario Road Network dataComparison between original ORN and optimized graph

Data Number of nodes Number of edges

Original vector data 37178 48765

Optimized graph 25928 36375

1125030%

1230025%

Page 14: Converting a spatial network to a graph Converting a spatial network

Integration of point data into networkIntegration of point data into network

Two guidelines:1 Find a representative node1. Find a representative node

for each point

2. Add a new edge to connect each point with the network

Page 15: Converting a spatial network to a graph Converting a spatial network

i. M nt to

t Mapping the ne a

each

Poi

nre

st p

oint

each poiarest node

Map

ping

eth

e ne

arint toe

iii.

Mh iii. A

dd a point

wee

n ea

cst

poi

nt

new edg

and the n dge

betw

e ne

ares

ge betwee

nearest n a ne

w e

dnt

and

the

en eachnode

iv. A

dd

poi n

Page 16: Converting a spatial network to a graph Converting a spatial network

Edge ReconstructionEdge Reconstruction

Edge splitEdge split_ iNew a A

l

Functions for recalculating attributes

_ ii

lNew a AL

Edge merge

_ max

_ mini

i

New a A

New a A

_ sum

_ meani

i

New a A

New a A

Page 17: Converting a spatial network to a graph Converting a spatial network

R package “shp2graph”p g p g p

Page 18: Converting a spatial network to a graph Converting a spatial network

R package “shp2graph”p g p g p

Page 19: Converting a spatial network to a graph Converting a spatial network

After conversion you canAfter conversion, you can…

• compute the shortest paths

• visualize the graph with igraph, shp2graph,visualize the graph with igraph, shp2graph,pajek

d k l i i h i ki d f• do network analysis with various kinds ofmethods available in graph, igraph, RBGL, etc

• ……

Page 20: Converting a spatial network to a graph Converting a spatial network

Future workFuture work

I was an R beginner when I started to developthis package, so… I make lots of mistakes!p g

• Awkward parameter settings in functions

• Poor coding style• Poor coding style

Topology correction functions will be developedin the near futurein the near future.

Page 21: Converting a spatial network to a graph Converting a spatial network

I will keep working on this, and welcome any contribution, suggestions or comments., gg

Page 22: Converting a spatial network to a graph Converting a spatial network

AcknowledgmentsAcknowledgments

• To Centre for Research into Statistical Methodology(CRISM) for funding me to attend this conference.

• Research presented in this paper is jointly funded bya Strategic Research Cluster grant (07/SRC/I1168) bya Strategic Research Cluster grant (07/SRC/I1168) byScience Foundation Ireland under the NationalDevelopment Plan and China Scholarship CouncilDevelopment Plan and China Scholarship Council(CSC).

Page 23: Converting a spatial network to a graph Converting a spatial network

Any comments or questions?