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:

dangles

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:

processing

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.

v.clean

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

TNGIC 2024

TNGIC 2024

So - if you're coming to the 2024 TNGIC (TN Geographic Information Council) meeting (April 9-11 2024) to talk about how no one understands what you do......I'm doing a workshop. What workshop? It's a new workshop. QGIS and LIDAR data. As to what I do with the class...

iNaturalist and QGIS

I am probably the worst for being able to properly name "things". There are big trees and little trees. There are the annoying bugs and the not so annoying bugs. There are ducks, birds, bigger birds, and the birds that hang out at my bird feeder. As much time as I...

Mergin Maps and DB Sync

Mergin Maps and DB Sync

I don't know if I would label this exercise as fun but I've learned alot. I don't do a ton of data collection these days. At one time a few years ago I was out in the field with Fulcrum, a laptop, and sketchy internet for days at a time. These days I'm hardly ever...