Einfache Netzwerkvisualisierung und Routing (QGIS3)

Creating, visualizing, and managing networks is an important part of GIS. Many types of physical infrastructure such as roads, railways, utilities can be modeled as networks with lines and nodes - with properties attached to them. In this tutorial, we will learn how road networks are commonly modeled and apply some styling techniques to visualize the routing properties. We will also use QGIS3’s built-in tools for network analysis that to find the shortest path between 2 points along with the network.

Überblick über die Aufgabe

We will take a layer of roadway block for Washington DC, visualize the connectivity and build a network to find shortest path between any 2 points in the city.

Weitere Fähigkeiten, die wir erlernen

  • Wie man vom Dateninhalt abhängige Vorgaben für die Symbolisierung der Linienrichtung mit einem Pfeil vorgibt.

Beschaffung der Daten

Die Regierung des Distrikts Columbia stellt hunderte Datensätze frei zur Verfügung: Open Data Catalog.

Download the Roadway Block shared by DCGISopendata data as a shapefile.

../../_images/data11.png

Der Einfachheit halber können wir eine Kopie der Datensätze unter folgenden links herunterladen:

Roadway_Block-shp.zip

Datenquelle: [DCOPENDATA]

Arbeitsablauf

  1. Locate the downloaded Roadway_Block-shp.zip file in the Browser panel. Expand it and drag the Roadway_Block.shp file to the canvas.

../../_images/115.png
  1. You will see a new line layer called Roadway_Block added to the Layers panel. This layer represents each road in Washington DC. Select the Identify tool in the Attributes Toolbar. Click on any road segment to see what attributes are attached to it. There are standard attributes like Route-name, Road-type etc. there is an attribute called SUMMARYDIR. This is an important attribute for routing as it specifies whether the segment is two-way or one-way. It contains 4 different values. BD (Both Directions) for two-way streets. OB (Out Bound) for one-way streets where the traffic is allowed in the direction of the line (start-point to end-point) and IB (In Bound) for one-way streets where the traffic flows in the opposite direction of the line. There is also ?? value where we will assume two-way traffic. We will now use the information in that attribute to display an arrow on one-way streets.

../../_images/213.png
  1. Klicke auf den Knopf Layergestaltungsfenster öffnen im Bereich Layer. Wähle Regelbasierend als Darstellung aus dem drop-down Menü aus.

../../_images/310.png
  1. Wir werden einen neuen Layerstil mit Hilfe eines Filters für Einbahnstraßen erstellen. Klicke auf den Knopf Regel hinzufügen.

../../_images/42.png
  1. Im Dialog Regel bearbeiten klicken wir auf den Knopf Ausdruck.

../../_images/52.png
  1. In the Expression string builder dialog, expand the Fields and Values section in the middle-panel. Select the SUMMARYDIR attribute and click All Unique in the right-hand panel. The 4 values that we discussed earlier will appear. Having these values here as a reference helps when building the expression. Also, you can double-click on any value to add them to the expression.

../../_images/62.png
  1. Unser Ziel ist es, einen Ausdruck zu erzeugen, der alle Einbahnstraßen selektiert. Wir geben den folgenden Ausdruck ein und klicken auf OK.

"SUMMARYDIR" in ('IB', 'OB')
../../_images/72.png
  1. Als nächstes ändern wir den Symbollayertyp zu Markierungslinie.

../../_images/82.png
  1. Wir wählen auf Mittelpunkt für die Markierungsplatzierung.

../../_images/92.png
  1. Klicke auf das Symbol Einfache Markierung, scrolle nach unten und wähle den Marker gefülltes Dreieck. Wir sehen das das einem Pfeil ähnelnde Symbol nun für die Einbahnstraßen angezeigt wird. Allerdings ziegen alle Pfeile in dieselbe Richtung, obwohl für die Einbahnstraßen mehrere Richtungen hinterlegt sind. Wir können die Symbolik weiter verfeinern indem wir eine vom Datensatz abhängige Richtung des Symbols unter Drehung vorgeben.

../../_images/105.png
  1. Klicke auf den Knopf Datendefinierte Übersteuerung neben Drehung.

../../_images/116.png
  1. We can put a conditional expression that returns different rotation values depending on the one-way direction. A 180° degree rotation for the road with opposite direction will make the direction perfect, In this, we will make the Roads with IB attribute rotate 180° hence all roads will have the correct traffic flow direction. Enter the following expression and click OK.

if( "SUMMARYDIR" = 'IB', 180, 0)
../../_images/125.png
  1. Now you will see the arrow-heads aligned to the correct road direction. To keep the style uncluttered, we are choosing to display arrows only on one-way streets. Unlabeled streets are assumed to be two-way. Now that we have the network styled correctly, we can do some analysis. Go to Processing ‣ Toolbox.

../../_images/134.png
  1. Wir suchen den Algorithmus Netzwerkanalyse ‣ Kürzester Weg (Punkt zu Punkt). Starte ihn mit einem Doppelklick.

../../_images/144.png
  1. In the Shortest Path (Point to Point) dialog, select Roadway_Block as the Vector layer representing network. Keep the Path type to calculate as Shortest. Next, we need to pick a start and endpoint. You can click the button and click on any point on the network in the canvas. If you want to replicate the results in this tutorial, you can enter -76.99730092166396,38.887624846748984 as the Start point and -76.99154831062152,38.89151000569929 as the End point. Expand the Advanced parameter section. Choose SUMMARYDIR as the Direction field. You must be familiar with the one-way direction values for the forward and backward traffic flow. Enter OB as the Value for the forward direction and IB as the Value for the backward direction. Keep other options to their default values and click Run.

../../_images/154.png
  1. The algorithm will use the geometry of the layer and provided parameters to build a network graph. This graph is then used to find the shortest path between the start and endpoints. Once the algorithm finishes, you will see a new layer Shortest path added to the Layers panel that shows the shortest path between start and endpoints.

../../_images/164.png
  1. You will see that there are many possible paths between start and endpoints. But given the constraints of the network - such as one-ways, the result is the shortest possible path. It is always a good idea to validate your analysis and assumptions. One easy way to validate it is to use a third-party mapping service to see if their results match with the ones we derived. Here is the shortest path suggested by Google Maps between the same start and endpoints. As you can see the recommended shortest route matches exactly with our results - validating our analysis.

../../_images/174.png

If you want to give feedback or share your experience with this tutorial, please comment below. (requires GitHub account)