{"word_count": 387, "character_count": 3488}
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 &#38; T.H.Keitt (2000) [2] E.Dobrzyńska &#38; 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.ioOpen your data a first time, and save it under the correct metric projection (SCR). Check your new .proj file to confirm changes.&#62;&#62;&#62; roads = QgsVectorLayer('~/roads.shp', 'roads', 'ogr')&#62;&#62;&#62; 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.&#62;&#62;&#62; roads = STSkeletonizeTheVoid(buildings_ExtRing).execute()&#62;&#62;&#62; nodes = STToRoadsSectionsNodes(roads).execute()&#62;&#62;&#62; QgsMapLayerRegistry.instance().addMapLayer(nodes)Because the lineStrings are not joined, intersections are found at each segment extremity.&#62;&#62;&#62; roads = STSkeletonizeTheVoid(buildings_ExtRing).execute()&#62;&#62;&#62; segmentNodes = STToRoadsSections(roads).execute()&#62;&#62;&#62; nodes = STToRoadsSectionsNodes(segmentNodes).execute()&#62;&#62;&#62; QgsMapLayerRegistry.instance().addMapLayer(nodes)Joining lineString segments before intersection extraction  [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.pdfRelated Topics Documentation overview Previous: Welcome to the T4QG Documentation Page Next: Creating GeometriesQuick search