Geometry validation tools (5) with QGis

In previous articles, we have discussed the geometry validation tools with ArcGis,Spatialite / Postgis, FME and Geomedia. We still have to discuss this feature with QGis. You will see, it is not easy to find it!

 First observation: the documentation does not exist (not yet?). Therefore you have to go through tests and see what happens.

Second observation: QGis proposes two tools for verifying geometries. This is not necessarily a problem, except that the results are not the same.

So, let’s start by discussing the available tools.

Geometry checkers in QGis 2.8

If you have followed a little the development of QGis in its different versions, you will understand that QSGis core increases from one version to the following by integrating optional plugins.

The available tools for geometry verification in version 2.8 originate in two old optional plugins:

  • The fTools plugin
  • The Topology checker plugin

There is no QGis documentation on how these plugins work when it comes to checking geometries. But, we can go back to find out the operational documentation of the old plugins, there is none.


The Topology Checker

To open the Topology Checker panel, click the Vector
-> Topology Checker -> Topology Checker

you must configure the verification rules, then click on the ” Validate
” button (all or just the visible layer).

To configure the rules, click the Configuration button.

The Topology Rules Settings window opens.

Select the layer to which the rule should be applied in the top left, and in the right field, select Must not contain invalid geometries

Click Add Rule to add the rule to the checklist

For the time being, we will limit ourselves to this rule, because it corresponds to the verification carried out by the tools we have already discussed.

To perform the verification, click Validate All

 The result is displayed in the panel window:

We find our 19 communes, the same as those detected by other software using the GEOS standards. The concerned communes are displayed in red on the map unlike the geometry part that is invalid. Therefore, it is difficult to know why an entity has been invalidated.

 It can be concluded that this tool uses GEOS geometries validation and that it works correctly.

Geometry validity check tool (fTools)

To open
the execution window of this tool, click on the menu Vector ->
Geometry tools -> Check validity of geometry

But before realising how to run the check, be aware that the check has two options,configurable from the Preferences -> Options menu and then Scan tab.

You can choose between using the GEOS or QGIS rules. Somehow, by reviewing all the tools in these articles, we can say that we are starting to figure out​​the rules used with the GEOS option. On the other hand, it would be wonderful to know what do the QGIS rules include!

 Do not count on it. Not a single line of documentation is available online. Anyway,the first who finds any clue wins our eternal gratitude.

But our problems do not finish here. If you choose GEOS and run the geometry check, QGis rises to the height of ArcGis (see our first example): the number of invalid geometries is ZERO!

It is impossible to know, without a hard work (that is totally useless), whether it never works or just in the case of our example layer. But even if you use the GEOS rules,use the QGis Topology Checker instead of this option, which might work in some cases, or not.

So, check that the default option (QGis) is there and let’s go back to our example.

To display the results you have two possibilities: If you leave the Save error location check box unchecked, the anomalies will be listed in the Geometry Errors window. Clicking on a line will display a cross at the location of the error.

  • So be it and check the Save
    error location
    box and enter a file name for the results layer.

But let’s look more closely the results obtained.

The window shows Total number of errors encountered: 129

We are far from the usual 19 errors in this test series.

A more precise study shows that, as in the case of Geomedia, this verifier does not stop at the first error found for an entity. Several errors can concern the same geometry.

The total number of communes (geometries) with errors is, in this case, 38. Twice what the other tests indicate. Of these 38 municipalities, 11 are included in the previous list of 19. Therefore, there are 8 communes which do not show errors in that test but do when using other methods. And, there are 27 communes that are considered as errors by this test and show no  problem if using the other methods.

 Let’s have a look at the first one to see if this test is right:

Obviously the test has pinpointed a geometry problem that had gone unnoticed until now with the other tools.

Now let’s look at the first of the communes that is marked as invalid by all the previous tests and as valid by this one:

The inner polygon is not detected as such: the red polygon consists of a single outer ring. This is, obviously, an error.

 So? What can we conclude? Given the lack of documentation, we cannot really know the reasons for these differences. In practice, all we have to do is telling us that the errors detected by the Topology Checker are the errors that(almost) all software agree to find.

 These can be corrected automatically with the MakeValid command of the lwgeom algorithm provider. We correct these errors and then we use the QGis Checker to see which other errors need to be corrected, but this time, manually.

In any case, it’s a shame that there is no documentation regarding the criteria used by the QGIS method because it seems to be more consistent than the usual method(GEOS).

Si cet article vous a intéressé et que vous pensez qu'il pourrait bénéficier à d'autres personnes, n'hésitez pas à le partager sur vos réseaux sociaux en utilisant les boutons ci-dessous. Votre partage est apprécié !

Leave a Reply

Your email address will not be published. Required fields are marked *