converting a spatial network to a graph converting a spatial network

Post on 02-Jan-2017

246 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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

ContentsContents

Motivation

Key points in the conversionKey points in the conversion

R package “shp2graph”

Future work

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”

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

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).

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

……

Topology errors

(a) Dangling arc (b) Undershoot

(c) Overshoot (d) Missing intersection

Connectivity ProblemConnectivity Problem

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

Over correction

Structure OptimizationStructure Optimization

43

2

1 2

10 98

12

14

1113

15

16

8

5 617 18 7

Pseudo-node

Multiple-edgeSelf-loop

Test on Ontario Road Network dataTest on Ontario Road Network data

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%

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

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

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

R package “shp2graph”p g p g p

R package “shp2graph”p g p g p

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

• ……

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.

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

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).

Any comments or questions?

top related