Network Analysis and Route Optimization

Network Analysis and Route Optimization

A few years ago a regional ambulance service asked me a deceptively simple question: “Where should we put our next station?” My first instinct was to draw circles on a map, five kilometers around each existing station, and look for gaps. It looked sensible and it was completely wrong. A hospital that is two kilometers away as the crow flies can be twenty minutes away if there is a river and the only bridge is far upstream. When we redid the analysis using the actual road network, the picture changed so dramatically that the best site moved to the other side of town.

That story captures the whole reason network analysis exists. People, vehicles, water and electricity don’t move in straight lines. They move along networks: roads, rails, footpaths, pipes, cables, rivers. If your question involves getting from here to there, the network, not the straight line, gives the honest answer. In this guide I’ll explain how network datasets work, which questions you can answer, how route optimization differs from simple shortest paths, and how to avoid the pitfalls.

Illustration: Network analysis finds the route with the lowest total cost, where cost can be distance, time or any weight.
Network analysis finds the route with the lowest total cost, where cost can be distance, time or any weight.

What Is a Network?

In GIS, a network is a set of connected linear features along which something can travel or flow. Mathematically it’s a graph, made of two kinds of elements:

  • Edges (links, segments): the lines. A road segment between two intersections.
  • Junctions (nodes, vertices): the points where edges meet or end. An intersection, a dead end, a valve.

What turns a collection of lines into a usable network is connectivity: the knowledge of which edges meet at which junctions. A road drawn as a picture is not a network until the GIS knows that it connects to the next one. This ties directly to the idea of topology in How Does GIS Work? Layers, Data, and Analysis Explained.

The attributes that give a network meaning

  • Length of each edge.
  • Travel time or speed: from speed limits or measured speeds.
  • Direction: one-way streets, flow direction in a pipe or river.
  • Restrictions: no entry for trucks, height limits, closed roads, pedestrian-only streets.
  • Turn rules: prohibited left turns, turn delays, U-turn rules.
  • Hierarchy: motorway, arterial, local street, which influences speed and preference.
  • Time-dependent data: traffic patterns by hour, opening hours of ferries.

Impedance, or cost

Every route calculation minimizes (or maximizes) a cost, also called impedance. The cost can be distance, travel time, money, fuel, risk or a weighted combination. The shortest route and the fastest route are different, and the “best” depends on what you choose to minimize.


The Core Questions Network Analysis Answers

1. Shortest or fastest path

What is the best route between two points? The classic algorithm for this is Dijkstra’s, and its faster relative A*, which use the network’s structure to find the lowest-cost path efficiently. You choose what “best” means: shortest distance, fastest time or lowest cost.

2. Service areas (isochrones)

What can be reached from a location within a given time or distance? The result is a polygon, called an isochrone when based on time, that traces the extent of access along the network. “Everything within ten minutes’ drive of the hospital”, “all homes within a five-minute walk of a park”. Unlike a buffer, it respects barriers and real travel.

3. Closest facility

Which of several facilities, such as hospitals, fire stations or shops, is nearest by travel cost to each incident or customer? The tool returns the best facility and the route to it.

4. Origin-destination (OD) cost matrix

The travel cost between every pair of several origins and destinations. This is the engine behind accessibility studies, market analysis and many optimization problems: for example, a table of travel times from each neighborhood to each school.

5. Location-allocation

Where should facilities be placed to serve demand as well as possible? Typical problems include:

  • Minimize impedance (p-median): choose p sites so that the total (or average) travel to demand points is as small as possible.
  • Maximize coverage: choose sites to cover as much demand as possible within a travel limit, such as 8 minutes for ambulances.
  • Minimize facilities: find the fewest sites that cover all demand.
  • Capacity constraints: limit how much demand each facility can serve.

This is how the ambulance service in my story found its new station.

6. Routing multiple stops: the TSP and the VRP

  • Traveling Salesman Problem (TSP): find the best order to visit a set of stops and return, with one vehicle.
  • Vehicle Routing Problem (VRP): assign many stops to several vehicles, and order them, respecting constraints such as vehicle capacity, time windows, working hours, skills and depot locations. It’s the heart of delivery, collection and field service planning.

7. Arc routing

Instead of visiting points, the vehicle must traverse edges: garbage collection, snow plowing, street sweeping, meter reading, inspection of every road. The problem is different from visiting stops, and has its own algorithms.

8. Tracing and flow analysis

In utility networks, where the question isn’t about getting somewhere but about connectivity: which customers lose water if this valve is closed? What is upstream of this pollution source? Which feeder powers this house? These are trace operations.


Shortest Path vs. Route Optimization

People often use the two terms interchangeably, but they are different levels of problem.

  • Shortest path: one origin and one destination. Easy and fast. An exact answer exists and is found quickly.
  • Route optimization: many stops, vehicles and constraints, and the goal is the best overall plan. These are known as combinatorial optimization problems, and they are computationally hard, because the number of possible orderings explodes. A tour of just 20 stops has more possible orderings than there are grains of sand on a beach.

For real-world problems, software doesn’t search every possibility. It uses heuristics and metaheuristics that find very good solutions quickly, without any guarantee of absolute perfection. That’s a critical point to remember: the result of a VRP solver is a good plan, not necessarily the mathematically best one, and its quality depends on the quality of your data and constraints.


The Data You Need

The network

  • Authoritative road data from your national mapping agency or local authority, often the best attributed.
  • OpenStreetMap, an extremely rich, global source of roads, paths and restrictions. Quality varies by region but is excellent in many places. See Where to Find Free GIS Data (Complete Source List).
  • Commercial network datasets, which include traffic, detailed speeds and restrictions, and cost money.
  • Your own data, for utilities, pipes or private roads.

Other inputs

  • Origins, destinations and facilities, as points, often created by geocoding addresses. See Geocoding: How to Convert Addresses to Coordinates.
  • Demand data: population, customers, orders and their quantities.
  • Constraints: vehicle capacities, shift times, delivery windows.
  • Traffic or speed profiles, if you need time-of-day realism.
  • Barriers: closed roads, floods, construction.

Preparing the Network: The Step That Decides the Result

Network analysis is unforgiving of data problems. A gap of one meter between two road ends can make a whole district unreachable.

  1. Check connectivity. Make sure lines that should connect do connect, with shared endpoints. Look for dangles, gaps and overshoots. Topology tools help, as described in Top 10 Most Common GIS Errors and How to Fix Them.
  2. Check direction. Verify one-way streets and their orientation. A reversed attribute can send routes the wrong way.
  3. Fill missing speeds and classes. Use sensible defaults by road type, and document them.
  4. Model restrictions and turns where they matter, especially for trucks and buses.
  5. Handle the real world: bridges and tunnels don’t connect to roads they cross. Overpasses must not create false junctions. Ferries, pedestrian-only links and private roads need correct rules.
  6. Choose the right network for the mode. The walking network, the cycling network and the driving network are different. Pedestrians can use footpaths and stairs, cars cannot.
  7. Snap points to the network sensibly. Origins and destinations rarely lie exactly on a road. The software snaps them to the nearest edge, and the snapping tolerance matters.
  8. Use a suitable projected CRS for length calculations. See Map Projections: How to Choose the Right One.

A Worked Example: Catchment of a Health Center

Question: how many people live within a 15-minute drive of the health center, and who is outside?

  1. Prepare the network from road data, with speeds by road class, one-way rules and a drive-mode setup.
  2. Locate the facility and snap it to the network.
  3. Compute a service area of 15 minutes, producing an isochrone polygon.
  4. Overlay the polygon with population data, using the techniques in Buffer, Clip, Intersect, Union: Overlay Tools Explained, apportioning population by area or, better, using population points or a gridded population layer.
  5. Calculate the number and percentage of people inside and outside.
  6. Map the result, showing the underserved areas.
  7. Test scenarios: what if a new bridge is built, or speed limits change? Re-run and compare.

Notice the contrast with a simple buffer. The isochrone follows roads and respects the river, the mountain and the missing bridge. It tells the truth that the circle hides.


Network Analysis in Code

With pgRouting (PostGIS)

pgRouting adds routing functions to a PostGIS database. A shortest path query between two nodes can look like this:

SELECT seq, node, edge, cost
FROM pgr_dijkstra(
  'SELECT id, source, target, cost, reverse_cost FROM road_edges',
  1,      -- start node
  250,    -- end node
  directed := true
);

The network table needs source and target columns identifying the junctions, and a cost. See PostGIS: A Practical Introduction for the database foundations.

With OSMnx and NetworkX (Python)

OSMnx downloads a street network from OpenStreetMap and builds a graph that NetworkX can analyze.

import osmnx as ox

# Download the drivable street network of a small city
G = ox.graph_from_place("Piedmont, California, USA", network_type="drive")

# Find the nearest network nodes to two coordinates (longitude, latitude)
orig = ox.distance.nearest_nodes(G, X=-122.245, Y=37.828)
dest = ox.distance.nearest_nodes(G, X=-122.230, Y=37.822)

# Shortest path by length
route = ox.shortest_path(G, orig, dest, weight="length")

The route is a list of node IDs. From here you can compute its length, plot it or convert it to a line layer. The wider Python toolkit appears in Geospatial Development & Automation: The Ultimate Guide.


Tools

  • QGIS: the Processing Toolbox includes Shortest path tools (point to point, layer to point), and Service area tools. The QNEAT3 plugin extends this with isochrones and OD matrices, and ORS Tools connects to the OpenRouteService. See Best GIS Plugins for QGIS.
  • ArcGIS Pro: the Network Analyst extension provides route, service area, closest facility, OD cost matrix, location-allocation and vehicle routing analysis layers, with a strong visual workflow.
  • pgRouting: server-side routing inside PostGIS, scalable and scriptable.
  • Routing engines: open-source engines such as OSRM, Valhalla and GraphHopper compute routes extremely fast on OpenStreetMap data, and are used behind many applications.
  • OpenRouteService: a service offering routing, isochrones and matrices, with public and self-hosted options.
  • OSMnx, NetworkX and similar libraries for custom analysis.
  • Specialized optimization software for large-scale vehicle routing.

Beyond the Basics

Accessibility measures

Network analysis underpins accessibility indices:

  • Cumulative opportunities: how many jobs, schools or shops are reachable within 30 minutes.
  • Gravity-based measures: weighting opportunities by how far they are, with nearer ones counting more.
  • Two-step floating catchment area: relating the supply of a service (doctors) to the demand (population) within reach, a common measure in health planning.

Multimodal and public transport

Real journeys combine walking, buses, trains and bikes. Public transport analysis uses schedule data (GTFS) to model timetables and transfers, producing time-dependent accessibility results.

Time-dependent and real-time routing

Travel times change with traffic. Advanced services use historical or live traffic. For a static analysis, say clearly which speeds you assumed.

Large-scale networks

For continental or national routing, specialized engines and preprocessing techniques make queries nearly instantaneous.


Common Mistakes

  • Using straight-line buffers when travel matters. The circle lies.
  • Broken connectivity, leaving parts of the network unreachable, or false connections where overpasses cross.
  • Wrong one-way attributes.
  • Using the wrong network for the mode, such as car roads for pedestrians.
  • Ignoring snapping effects. Points snapped to the wrong road can change a route dramatically.
  • Assuming free-flow speeds for rush hour analysis.
  • Treating a heuristic solution as the proven optimum.
  • Over-constraining the problem, so that the solver finds no feasible solution, or under-constraining it, producing unrealistic plans.
  • Ignoring data quality in the origins and destinations, such as badly geocoded addresses.
  • Presenting results without stating assumptions: speeds, restrictions, time of day, mode and network source.
  • Forgetting the human side: a plan that is mathematically efficient but ignores drivers’ breaks, customer preferences or local knowledge will fail in practice.

How to Judge a Result

  • Sanity check routes against your local knowledge. Do they follow roads that drivers would actually take?
  • Compare network distance with straight-line distance. The ratio, sometimes called the circuity factor, is usually between 1.2 and 1.5 in urban areas. Values far outside that range deserve investigation.
  • Test sensitivity: change speeds or restrictions slightly, and see whether the results are stable.
  • Validate with real data, such as measured trips, GPS traces or known response times, when you can.
  • Document assumptions and data sources, following the habits in Metadata in GIS: Why It Matters and How to Create It.

Final Thoughts

Network analysis is where GIS stops describing space and starts describing movement and access, the thing people actually experience. It answers questions that decide where ambulances wait, where schools open, where trucks go and how long people travel to reach what they need. It also rewards care: a clean, well-connected network, honest assumptions and a healthy skepticism toward any result that looks too tidy.

Take a facility you know, a school or a clinic, and compute its ten-minute service area on foot and by car. Compare both with a simple circle. The difference you see is the reason this technique matters.

Where to go next: continue with Digital Elevation Models (DEM) and Terrain Analysis, where terrain shapes the cost of movement, and revisit Spatial Analysis in GIS: Complete Guide to see how network tools fit among the others.

Rachid Khouri

Rachid Khouri

Rachid Khouri is a CAD, BIM and GIS professional, Autodesk Authorized Developer, trainer and technical author with more than 30 years of experience, working with AutoCAD since 1992. He founded GISauthority.com to share practical guidance on GIS and spatial technologies.