Project

General

Profile

Task #8384

Applying Topology Rules to Basins using QGIS 3.6.*

Added by Debojyoti Mallick over 2 years ago. Updated over 2 years ago.

Status:
Feedback
Priority:
Normal
Start date:
28/05/2019
Due date:
% Done:

100%

Close

Description

Applying Topology Rules to refine borders of Basins using QGIS.

Used Check Geometry and Topology Checker to try and correct ends of basins.

Some Basins looked good and followed the correct rule for overlap while a few of them did not.

Checking through all the rules to eventually look at the possibility of removing the faulty overlaps automatically. Else will have to resort to manual editing for them.

AfterCheckGeometry.png View (107 KB) Debojyoti Mallick, 07/06/2019 11:14

AfterDissolve2.png View (242 KB) Debojyoti Mallick, 07/06/2019 11:14

AttributeforDissolve.png View (95.8 KB) Debojyoti Mallick, 07/06/2019 11:14

BeforeCheckGeometry.png View (98.9 KB) Debojyoti Mallick, 07/06/2019 11:14

BeforeDissolve2.png View (100 KB) Debojyoti Mallick, 07/06/2019 11:14

Dissolve Problem1.png View (192 KB) Debojyoti Mallick, 07/06/2019 11:14

JoinwithDrain.png View (68.7 KB) Debojyoti Mallick, 07/06/2019 11:14

Dissolve.png View (38.3 KB) Debojyoti Mallick, 07/06/2019 12:06

After.png View (29.3 KB) Debojyoti Mallick, 07/06/2019 15:27

Before.png View (31.4 KB) Debojyoti Mallick, 07/06/2019 15:27

5474
5475
5476
5477
5478
5479
5480
5483
5489
5490

History

#1 Updated by Debojyoti Mallick over 2 years ago

5474
5475
5476
5477
5478
5479
5480
5483

Debojyoti Mallick wrote:

Applying Topology Rules to refine borders of Basins using QGIS.

Used Check Geometry and Topology Checker to try and correct ends of basins.

Some Basins looked good and followed the correct rule for overlap while a few of them did not.

Checking through all the rules to eventually look at the possibility of removing the faulty overlaps automatically. Else will have to resort to manual editing for them.

Check Geometry and Topology Checker cannot be used to correct overlaps as both of them define an overlap only considering how the boundaries of polygons are shared with one another.
This defeats the purpose as the overlaps should be eliminated by the logic of the catchment points inside the basin and the direction of the drain to the lowest catchment area.

Only using simple Topology checks results in such anomalies.

Before using Check Geometry

As you can see in the image above the overlaps are removed but they do not respect the direction of the drains nor do they respect the location of the catchment points.

Second alternative which was used was VClean using GRASS toolbox.

This uses the Topology Checker results to eventually clean the overlaps. This does give much better results but still creates some similar anomalies as discussed before. In addition to this it also automatically eliminates Silver Polygons which is not ideal as it would eventually eliminate the sub-basins and very small catchment areas.

To resolve geometric errors inclusive of Drains and Catchment points we did not use simple Topology rules as QGIS does not give the option of relations between points, lines and polygons.

Hence we use basic spatial concepts like Spatial Joins, Merge and Dissolve.

We first run a Spatial Join (Join by Location) between the Basins (Polygons) and the Drains (Lines)
A single attribute table with both results gives us more control.

The resulting layer is as follows.

As the above figure shows, we can now see all the defined shapes of the basins and this will not show any overlaps.
This is now used as a base layer and we use the drain numbers to run our dissolve.

The resulting layer is not correct as consecutive drain numbers do not necessarily lead to or belong to the same basin.

Hence we have to include the catchment points and use those as a reference to define the boundaries for the basins.
On checking the attribute table the Basin column in the catchment points is a very reliable attribute to work with.

Hence ran a Spatial Join between the Basins, Drains and the Catchment Points.

We now run GDAL Dissolve using the Catchment Points as a reference.

The results are good but we do have a few anomalies as the tool cannot decide the borders of the certain basins.

!Dissolve Problem1.png!

As per the image above, you will see that the polygons have been merged because the dissolve tool was not able to decide where the point belongs. But this is the only anomaly with regards to a single point.

Keep in mind that we have considered the true definition and use of Dissolve illustrated below.

But the difference here is the fact that we are using the Catchment Points as the defining variable hence it should not merge the polygons rather define the borders of the basins (by eradicating unnecessary overlaps).

A similar issue of Merging Polygons occurs when there are multiple catchment points between two polygons.
The GDAL Dissolve tool is unable to decide the correct outline of the basin in such areas.

In the image above you can see another case of merged polygons.

The rest of the layer does not show this problem as 80% of the overlaps are eradicated correctly.

Hence we use Dissolve in Python/GeoPandas rather than use the GDAL tool in QGIS to check if the same issue is replicated.

There seems to be an issue with Jupyter with regards to reading files

gdf = gpd.read_file('SandBox/Debo/data/ExtractedBasin6more_reduced.shp')

Unfortunately files cannot be read. I will run this once it has been resolved.

Hence running it on VSCode to check the results. Takes time because of the hardware incompetence of my machine. Will be running this on a desktop to check the results.

#2 Updated by Debojyoti Mallick over 2 years ago

Debojyoti Mallick wrote:

Debojyoti Mallick wrote:

Applying Topology Rules to refine borders of Basins using QGIS.

Used Check Geometry and Topology Checker to try and correct ends of basins.

Some Basins looked good and followed the correct rule for overlap while a few of them did not.

Checking through all the rules to eventually look at the possibility of removing the faulty overlaps automatically. Else will have to resort to manual editing for them.

Check Geometry and Topology Checker cannot be used to correct overlaps as both of them define an overlap only considering how the boundaries of polygons are shared with one another.
This defeats the purpose as the overlaps should be eliminated by the logic of the catchment points inside the basin and the direction of the drain to the lowest catchment area.

Only using simple Topology checks results in such anomalies.

Before using Check Geometry

As you can see in the image above the overlaps are removed but they do not respect the direction of the drains nor do they respect the location of the catchment points.

Second alternative which was used was VClean using GRASS toolbox.

This uses the Topology Checker results to eventually clean the overlaps. This does give much better results but still creates some similar anomalies as discussed before. In addition to this it also automatically eliminates Silver Polygons which is not ideal as it would eventually eliminate the sub-basins and very small catchment areas.

To resolve geometric errors inclusive of Drains and Catchment points we did not use simple Topology rules as QGIS does not give the option of relations between points, lines and polygons.

Hence we use basic spatial concepts like Spatial Joins, Merge and Dissolve.

We first run a Spatial Join (Join by Location) between the Basins (Polygons) and the Drains (Lines)
A single attribute table with both results gives us more control.

The resulting layer is as follows.

As the above figure shows, we can now see all the defined shapes of the basins and this will not show any overlaps.
This is now used as a base layer and we use the drain numbers to run our dissolve.

The resulting layer is not correct as consecutive drain numbers do not necessarily lead to or belong to the same basin.

Hence we have to include the catchment points and use those as a reference to define the boundaries for the basins.
On checking the attribute table the Basin column in the catchment points is a very reliable attribute to work with.

Hence ran a Spatial Join between the Basins, Drains and the Catchment Points.

We now run GDAL Dissolve using the Catchment Points as a reference.

The results are good but we do have a few anomalies as the tool cannot decide the borders of the certain basins.

!Dissolve Problem1.png!

As per the image above, you will see that the polygons have been merged because the dissolve tool was not able to decide where the point belongs. But this is the only anomaly with regards to a single point.

Keep in mind that we have considered the true definition and use of Dissolve illustrated below.

But the difference here is the fact that we are using the Catchment Points as the defining variable hence it should not merge the polygons rather define the borders of the basins (by eradicating unnecessary overlaps).

A similar issue of Merging Polygons occurs when there are multiple catchment points between two polygons.
The GDAL Dissolve tool is unable to decide the correct outline of the basin in such areas.

In the image above you can see another case of merged polygons.

The rest of the layer does not show this problem as 80% of the overlaps are eradicated correctly.

Hence we use Dissolve in Python/GeoPandas rather than use the GDAL tool in QGIS to check if the same issue is replicated.

There seems to be an issue with Jupyter with regards to reading files

gdf = gpd.read_file('SandBox/Debo/data/ExtractedBasin6more_reduced.shp')

Unfortunately files cannot be read. I will run this once it has been resolved.

Hence running it on VSCode to check the results. Takes time because of the hardware incompetence of my machine. Will be running this on a desktop to check the results.

Ran the dissolve using GeoPandas on Jupyter using a geopackage. Same results worried

This was the code used:

import geopandas
gdf = geopandas.read_file('data/Extractedbasin6_geopack.gpkg').to_crs({'init' :'epsg:4326'})

import numpy as np

gdf.plot(color='white', edgecolor='black')

import matplotlib.pyplot as plt
import matplotlib.lines as mlines
from matplotlib.colors import ListedColormap

gdf.geom_type.head()

Basin_bound = gdf'basin', 'geometry'

Basin_dissolve = Basin_bound.dissolve(by='basin')

Basin_dissolve

Basin_dissolve.plot(color='white', edgecolor='black')

#Gives the same result

This concludes that there is no issue with the GDAL Dissolve and the logic used to get the output is flawed.

Will check for alternatives.

#3 Updated by Debojyoti Mallick over 2 years ago

5489
5490

Debojyoti Mallick wrote:

Debojyoti Mallick wrote:

Debojyoti Mallick wrote:

Applying Topology Rules to refine borders of Basins using QGIS.

Used Check Geometry and Topology Checker to try and correct ends of basins.

Some Basins looked good and followed the correct rule for overlap while a few of them did not.

Checking through all the rules to eventually look at the possibility of removing the faulty overlaps automatically. Else will have to resort to manual editing for them.

Check Geometry and Topology Checker cannot be used to correct overlaps as both of them define an overlap only considering how the boundaries of polygons are shared with one another.
This defeats the purpose as the overlaps should be eliminated by the logic of the catchment points inside the basin and the direction of the drain to the lowest catchment area.

Only using simple Topology checks results in such anomalies.

Before using Check Geometry

As you can see in the image above the overlaps are removed but they do not respect the direction of the drains nor do they respect the location of the catchment points.

Second alternative which was used was VClean using GRASS toolbox.

This uses the Topology Checker results to eventually clean the overlaps. This does give much better results but still creates some similar anomalies as discussed before. In addition to this it also automatically eliminates Silver Polygons which is not ideal as it would eventually eliminate the sub-basins and very small catchment areas.

To resolve geometric errors inclusive of Drains and Catchment points we did not use simple Topology rules as QGIS does not give the option of relations between points, lines and polygons.

Hence we use basic spatial concepts like Spatial Joins, Merge and Dissolve.

We first run a Spatial Join (Join by Location) between the Basins (Polygons) and the Drains (Lines)
A single attribute table with both results gives us more control.

The resulting layer is as follows.

As the above figure shows, we can now see all the defined shapes of the basins and this will not show any overlaps.
This is now used as a base layer and we use the drain numbers to run our dissolve.

The resulting layer is not correct as consecutive drain numbers do not necessarily lead to or belong to the same basin.

Hence we have to include the catchment points and use those as a reference to define the boundaries for the basins.
On checking the attribute table the Basin column in the catchment points is a very reliable attribute to work with.

Hence ran a Spatial Join between the Basins, Drains and the Catchment Points.

We now run GDAL Dissolve using the Catchment Points as a reference.

The results are good but we do have a few anomalies as the tool cannot decide the borders of the certain basins.

!Dissolve Problem1.png!

As per the image above, you will see that the polygons have been merged because the dissolve tool was not able to decide where the point belongs. But this is the only anomaly with regards to a single point.

Keep in mind that we have considered the true definition and use of Dissolve illustrated below.

But the difference here is the fact that we are using the Catchment Points as the defining variable hence it should not merge the polygons rather define the borders of the basins (by eradicating unnecessary overlaps).

A similar issue of Merging Polygons occurs when there are multiple catchment points between two polygons.
The GDAL Dissolve tool is unable to decide the correct outline of the basin in such areas.

In the image above you can see another case of merged polygons.

The rest of the layer does not show this problem as 80% of the overlaps are eradicated correctly.

Hence we use Dissolve in Python/GeoPandas rather than use the GDAL tool in QGIS to check if the same issue is replicated.

There seems to be an issue with Jupyter with regards to reading files

gdf = gpd.read_file('SandBox/Debo/data/ExtractedBasin6more_reduced.shp')

Unfortunately files cannot be read. I will run this once it has been resolved.

Hence running it on VSCode to check the results. Takes time because of the hardware incompetence of my machine. Will be running this on a desktop to check the results.

Ran the dissolve using GeoPandas on Jupyter using a geopackage. Same results worried

This was the code used:

import geopandas
gdf = geopandas.read_file('data/Extractedbasin6_geopack.gpkg').to_crs({'init' :'epsg:4326'})

import numpy as np

gdf.plot(color='white', edgecolor='black')

import matplotlib.pyplot as plt
import matplotlib.lines as mlines
from matplotlib.colors import ListedColormap

gdf.geom_type.head()

Basin_bound = gdf'basin', 'geometry'

Basin_dissolve = Basin_bound.dissolve(by='basin')

Basin_dissolve

Basin_dissolve.plot(color='white', edgecolor='black')

#Gives the same result

This concludes that there is no issue with the GDAL Dissolve and the logic used to get the output is flawed.

Will check for alternatives.

Just to give a clearer output with the code on Jupyter:

Before

After running Dissolve

#4 Updated by Debojyoti Mallick over 2 years ago

  • Status changed from New to In Progress

#5 Updated by Debojyoti Mallick over 2 years ago

  • Status changed from In Progress to Feedback
  • % Done changed from 0 to 100

Also available in: Atom PDF