Friday 18 May 2018

qgis - Cutting all polygons with each other - mega slicing


Draw a big circle. Then a smaller one on top and then a smaller one and a smaller one.


You see a stack of circles like a bulls eye. If you had drawn these in QGIS the other way you would only see the largest one as it hides the others.


Is there a way in a single layer to slice every feature with every other?


Basically i have contours and i only want the band between each polygon rather than the stack of progressively bigger polys like the bulls eye example.


I have perfect data where all polygons are closed and sit perfectly inside each other.



Answer




If the contours are line feature class and are closed contour lines, as you can see below:


enter image description here


then you need to use lines to polygons tool from Processing toolbox -> QGIS geoalgorithoms -> Vector geometry tools -> lines to polygons


It will give you the following output, which is topologically not correct (Overlapping each other):


enter image description here


To modify the above topology, you need to use GRASS -> v.clean as @Klewis suggested from Processing toolbox -> GRASS GIS 7 commands -> Vector -> v.clean, and in cleaning tool use Break, as you can see below:


enter image description here


The output result is now topologically correct:


enter image description here


I selected a polygon in the above image to show you that it is a valid topology.



If the contours are already polygons in separate shapefiles, you can use difference tool repeatedly to get the difference between big polygons and smaller polygons and finally use Merge tool to put them in one polygon shapefile.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...