Creating Graphs
Creating Graphs¶
This section explains the basic built-in functionalities pertaining to urban graph analysis.
The two principal elements of an urban graph are vertices and edges. Generally, a vertex corresponds to the intersection of mutiple edges. In Urban Planning, vertices correspond to intersection points, and edges correspond to linear road data.
There is an extensive collection of scholarly articles pertaining to graph theory with concrete GIS applications:
- J.K.Tinkler (1977) [1]
- A.G.Bunn, D.L.Urban & T.H.Keitt (2000) [2]
- E.Dobrzyńska & M.Dobrzyński (2016) [3]
Downloading Data¶
A real urban graph is derived from road data. It follows the existing street pattern to fit with the physical reality of the terrain.
This type of data is usually found online, in open access from official sources or from open-source.
T4QG relies on metric Cartesian coordinates for a few of its functionalities. Open the .proj
file connected to your data and check in what type it is currently projected.
If your original data is in lat/lon, you can find the metric alternative on https://epsg.io
Open your data a first time, and save it under the correct metric projection (SCR). Check your new .proj
file to confirm changes.
>>> roads = QgsVectorLayer('~/roads.shp', 'roads', 'ogr')
>>> QgsMapLayerRegistry.instance().addMapLayer(roads)
You may find more information concerning Loading Vectorial Datasets in Qgis at the official documentation page.
Extracting Nodes¶
To extract intersection nodes from lineStrings:
STToRoadsSectionsNodes
(layer).execute()¶-
Parameters: layer (QgsVectorLayer) – a LineString vector layer. Returns: A Vector Layer wherein points are created at each intersection of more than two LineStrings of the input layer.
An alternative method for creating an urban graph may also be built using the surrounding urban morphology.
This process, called skeletonization, requires a layer of polygons representing the built form.
To learn how to build the skeleton of the built environment, head to the page on Creating Geometries.
The lineString layer returned by STSkeletonizeTheVoid()
needs to be joined using STToRoadsSections()
to extract the intersections correctly.
To clean the linestring data before processing :
STToRoadsSections
(layer).execute()¶-
Parameters: layer (QgsVectorLayer) – a LineString vector layer. Returns: A Vector Layer wherein the input linestrings are joined when they intersect a single other linestring, and split at the intersection of more than two linestrings.
>>> roads = STSkeletonizeTheVoid(buildings_ExtRing).execute()
>>> nodes = STToRoadsSectionsNodes(roads).execute()
>>> QgsMapLayerRegistry.instance().addMapLayer(nodes)
>>> roads = STSkeletonizeTheVoid(buildings_ExtRing).execute()
>>> segmentNodes = STToRoadsSections(roads).execute()
>>> nodes = STToRoadsSectionsNodes(segmentNodes).execute()
>>> QgsMapLayerRegistry.instance().addMapLayer(nodes)
[1] | http://journals.sagepub.com/doi/pdf/10.1177/030913257900300104 |
[2] | http://www.sciencedirect.com/science/article/pii/S0301479700903736 |
[3] | https://www.degruyter.com/downloadpdf/j/emj.2016.8.issue-4/emj-2016-0033/emj-2016-0033.pdf |
OpenEdition vous propose de citer ce billet de la manière suivante :
khartwell (15 décembre 2017). Creating Graphs. Métrologie des ambiances urbaines. Consulté le 9 octobre 2024 à l’adresse https://doi.org/10.58079/rar8