Topology: QGIS Geometry Checker and other tools

Aug 25, 2020 | 911, QGIS

So lets dive more into “I need to fix my data”. In this case I have two layers – one is polygon and one is linestring.The polygon layer has overlaps and gaps. The linestring layer has dangles and is not intersected correctly causing more dangles. We looked at the polygon in the last post….and that’s what we will start with….and we have 208 errors which are gaps. The errors are the red lines you see along the borders.

So how am I going to fix this? Well I can always zoom to each error and manually fix it. It’s a slow go but At least I know what’s happening. If I think back to the ESRI world it seems their topology tool automatically fixes errors. Well – automatically with some intervention but it’s faster than manual.

Which brings us to this tool called Geometry Checker. It’s a plugin but it’s part of QGIS Core so you have it when you install QGIS. The goal is to clean up errors and it also has the added bonus to run some checks on your data.

Geometry Checker lets me look at some additional things like duplicate nodes. A Check for gaps. A Check for self intersections. A Check for smaller sliver polygons. It will also check to see that the layer you are working with follows the boundaries of a second layer. So do I need to check that this layer fits with the county? I probably should. So I’m going to check for polygons smaller than 1 square mile. Holes. Overlaps smaller than 1 square mile. Gaps bigger than 10 square miles. Which at this point there is no method to my madness – more just testing things to see what comes up.

You have 2 options at the end of this. One is to edit the layers “in place” which means the originals get changed. The other option is geopackage. As all my data is currently in postgis and I hate the idea of “edit in place” – I’m going to a geopackage and fix my data and then shove it back into the database.

When geometry checker is run a new geopackage is created. I am prompted with a list of errors I can work my way through and click a button to automatically fix the problem. I also have a setting for “error resolution settings” which will let me set some defaults like “merge the sliver polygons into the largest shared edge”. Overall it’s pretty awesome. It appears I can even fix more than one error at a time. I didn’t have much luck doing that BUT – I’m happy with one at a time in most cases.

What about the roads?

I have a road layer with roads that aren’t properly intersected. The Topology Checker works great and I can find them all…..so the Geometry Checker……

If you look at the Geometry checker I can check line strings for length, dangles, self intersection and a few other things. What I don’t get is a way to fix dangles like I have pictured above. Which sorta brings me to “I need a way to snap and break lines at intersections easily”. I can manually do it – but if I have a bad road layer (water lines, linear anything) that can be a pain to walk through.

but……there’s always a but…..

There are 2 tools in 3.14 (maybe earlier but that’s what I’m using) called Snap and Split Lines with Lines. So I’m going to run a Snap Geometries to Layer and then a Split Lines with Lines against the snapped layer and my Dangle issue almost goes away. Roads are always going to have dangling nodes – lets just not have them in the middle of the road. No i go back to Geometry Checker and look for duplicate nodes and other things.

So I have some tools to fix my data. Here would be my pros and cons:

Pros:

  • You can fix your data. Be it a shapefile, geopackage, postgis table, etc – the tools work. It’s a lot of tools also – if you’re coming from the ArcGIS world where you have to have a licensing level to run topology – you don’t have that problem anymore. You don’t have a table/data layer called topology – but you have a lot of tools to clean up your data and make it topologically correct.
  • New tools are coming constantly. I had a game plan for writing this article and discovered Snap and Break Lines with Lines. So if it seems like I shoved that in at the last minute (I did).

Cons:

  • You’ll notice back in the article you’ll notice I didn’t really give numbers on problems found. The Topology Checker would notice 208 gaps in my data and Geometry Checker would find 384. They are two different tools that (to me) serve two different purposes. So one might report more. One might report less. I would use both as a running check on my data and I might use topology checker throughout the day and geometry checker at the end of the day.
  • It’s not really a con – but when you’re fixing your data you may pull that data out of the original table (as I did) to fix it and then push your fixed data back into the database. Maybe I make a new table. I’m not sure on workflow yet so maybe this comes toward the end of the project.

One final word on Geopackage…..

One thing I have sort of taken for granted is geopackage. I say geopackage a lot. When I teach a class I yell geopackage. It wasn’t until I wrote this that I noticed everything is dumping back to geopackage. Some GRASS tools sometimes went back to shapefile in previous versions. It seems like there were a few tools that would in QGIS that wanted to go back to shape – it’s all Geopackage now. It’s nice.

—BUT—

Maybe I don’t want this much work fixing my data. I have geometry checker….and I have some tools from the processing toolbox……what if I wanted one tool to run my topology checks BECAUSE I’m really wanting to network these roads together…..what could that tool be………..those tools be…….

 

 

 

 

 

 

 

 

 

You may also like

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?"....

The TN 911 Project

So next week is the TN GIS meeting at Montgomery Bell State Park. Which will be the first conference I've walked into in 2 years and 2 months. I'm doing two things while I'm there - well three: Walk a lot Teach an OSM workshop Give a talk on the 911 project. So - the...