Thursday, 16 May 2019

pyqgis - Splitting rectangles into a desired number of parts in QGIS


I'm working on a project using QGIS and there is a process that I'd like to try to automate. I'm working with the "rectangles,ovals digitizing tool" plug-in to make perfect rectangles. The next step in my process is to split these rectangles horizontally and vertically in equal intervals in order to make many smaller equal-area rectangles as shown in the picture below.


splitting rectangles


I am currently using a help line layer and the plug-in "qchainage" to split the lines equally across each side of the rectangle. Then I use snapping to cut the polygon where the vertices's were created. This process isn't bad, but it's getting too slow and opens a door for manual mistakes.


I'd like to find or develop a plug-in or a script, where I can input a selected rectangle, an integer m for the number of parts I want to split the short side to and another integer n for the number of parts I want to split the long side to. In the example above - m = 2 , n = 5 .


I've tried to learn from this discussion, but didn't find what I was looking for. I've written a few scripts using pyqgis so if anyone has a suggestion I can try to implement it.




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