QGIS Topology and Emergency

Jun 26, 2016 | ArcGIS Desktop, GRASS, QGIS

I’m 44. When I was a kid probably one of my favorite shows was Emergency. Never seen it? You are missing out. Not terribly long ago I bought a digital antennae for a television and I discovered it’s on everyday. I had toy firetrucks and lego skyscrapers and everything but the best prop a TV firefighter/paramedic could have  – fire. Sweet Sweet fire……

Anyway – I had a former QGIS Student give me a shout last week.  They were asked to display in their GIS 5 mile road distances from Fire Stations. So every fire station needed a 5 mile distance band (not a buffer) to help with their ISO rating for insurance. I’ve never worked for a county but I’ve met people who do this and have had people describe the process. They are an ESRI shop. They don’t have any of the extensions. They have QGIS. QGIS fills in where they need extended functionality.

So the first thing I did was recreate this blog post. I pulled the Data into GRASS 7.0.4 and built a network and produced a 5 mile distance band. Except there was this one problem. The road shapefile (I hate shapefiles) wasn’t snapped everywhere so the distance band was wrong. I pulled the original shapefile into QGIS and used the Topology tool to take a quick look:


Every road should have anywhere from one to no red dots. As you can see several have two – one at the beginning and one at the end. In some cases you had roads that didn’t intersect and some where the roads just didn’t meet up. You also had some duplicated data.

So how do you fix it? Do you go road by road and check it? I actually like that idea and whole-heartily support it BUT…..there needs to be a quicker way to fix this. This is where ESRI is awesome if you have ArcEditor or ArcINFO or ArcGIS for Desktop Extended Enterprise Universe something. You can import your data into a Geodatabase and build some topology. Unless you’re stuck with Arcview………..

I sat down and started reading about v.clean in GRASS. V.clean gives you several tools from intersecting lines, to snapping, to removing dangles in data. GRASS is a topological GIS. Shapefiles aren’t topological. So I started writing directions on this small county shop to pull their data into GRASS. GRASS doesn’t scare me – it scares most GIS people.

Over the last year the processing tools have kept getting better and better in QGIS. If you’ve downloaded QGIS go to the processing menu and open the toolbox. It looks a lot like ArcToolbox. The Processing Toolbox gives you functionality from other software like GRASS and GDAL. You can search for v.clean:


So this is really turning into something a lot easier than I’d hoped.

I decided I needed three tools from v.clean: snap, break, remove dangle. So I ran it three times – once for each tool. Snap made sure lines met. Break intersected the roads. Remove dangle removed very small overshoots.


When I finished my cleaning of road data:

snapping data

I took a look before I ran clean and I had 3200+ errors in QGIS. After I had 2600+ errors. I fixed a lot of things. I most likely messed a few things up. That’s why you run things with a small threshold or tolerance. I cleaned a shapefile. One command later (v.net.iso) and:

qgis desktop

I networked my now clean shapefiles. They have their distance band for the fire station.

The plus on this is v.clean didn’t fundamentally change their data. Uppercase field names remained uppercase. The isoline portion did change the data as I lost some of my attributes and added one field (but that’s fixable).

Pro: Free Software It works. It’s now a documented process (that will get posted up here shortly). You don’t have to leave QGIS to run your tools.

Con: It does produce more than a few data files. The process is a bit convoluted. Shapefiles. It doesn’t work in GRASS 7.0.3 so you need 7.0.4.

The most important part:  the county can process data to help their citizens.

So I get to the end of this and I know what you’re thinking. OMG who the freak wants to run data through GRASS? It works. You know what I’m thinking? OMG I hate shapefiles so how do I do this in PostGIS? The GRASS Tools are still exporting to shapefile. If I jump into GRASS I can push data back and forth to PostGIS.

Of course there are topology tools in PostGIS…………

You may also like

ESRI’s File Based Geodatabase and QGIS

With QGIS 3.28.1 being released you get this one new thing that I thought I'd never see. Way back in June (2022) this popped up on twitter: Yes - GDAL 3.6 would have the ability to edit ESRI File Based Geodatabases. Back in 2014 GDAL gained the ability to read an ESRI...

Beck Knob Project

Beck Knob Project

If I ever had to stand behind one thing I've learned as a business and working in Geo - there is no end to free work. A few years ago I had to do a hard stop on volunteer projects and settle on one a year. That one can be one week in length. It can be 6 months. It can...

QGIS Support Redux

Back to QGIS ramblings. I mentioned in a previous blog post I was doing QGIS support specifically for one company but in reality it's been about every client where I install QGIS. The one company turned into a retainer where I tested the waters of "can I do this?"....