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:
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:
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…………