I currently have an algorithm which turns a polygon drawn on a map into a contiguous set of 100m^2 chunks. Sometimes the algorithm fails and I end up with chunks missing and a diagonal line remains part of my polygon.
I'm working on fixing the algorithm but in parallel, I'm looking for a way to check that my new polygon bordering my collection of chunks contain no diagonal lines.
Asked
Active
Viewed 115 times
1
SAR622
- 121
- 4
-
1A logic I can think of assumes you are rasterizing your polygon to create your stepped appearance as discussed by@xunilk below. By rasterizing you are imposing a fixed edge length defined by the cell size. So lets say you are rasterizing to a 100m resolution. Explode the polygon into line segments (consisting of just 2 vertices) and any segment not exactly 100m is most likely to be a diagonal line. Then you have found a polygon you need to check? – Hornbydd Nov 28 '19 at 23:38
-
That's great and should work. I'll check each segment if it's a multiple if 100m and flag any that are not. Problem (I think) solved! – SAR622 Nov 29 '19 at 05:55
1 Answers
2
You don't show any code of your algorithm so, it is difficult to find why the algorithm fails. However, following QGIS workaround can be used for developing an alternative algorithm with python. First, I created a triangular layer similar to your layer.
Buffering it by 100 meters with Buffer tool from Processing Tool Box:
Rasterizing buffer with a resolution of 100x100, you already have a contiguous set of 100 m^2 chunks.
Afterward of poligonize above raster with 'Raster Pixels to polygons' Processing Tool Box, it can be corroborated.
Finally, Dissolving by VALUE field, it can be obtained desired vector layer.
xunilk
- 29,891
- 4
- 41
- 80
-
Thanks so much but I was asking a different question. What is an method to check that all the lines in my polygon are snapped to the grid lines - i.e. no diagonals. – SAR622 Nov 28 '19 at 18:34






