3

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.

  • 1
    If you can write scripts, why not just write one that solves your problem? It's not very hard to figure out where to draw the horizontal and vertical lines once you know your m and n. Just some bookkeeping to collect the proper corner coordinates for each smaller rectangle. What part of that problem do you need help with? – Jon Aug 22 '18 at 14:55
2

You could try using the Polygon Divider plugin which allows you to divide your polygons to a specified size. You can download this from the menubar:

Plugins > Manage and Install Plugins

Example:

  1. A rectangle with an area ~100,000 m2:

    Rectangle

  2. Executing the plugin to create 'parts', each with an area of 10,000 m2:

    Result


You could also check the source code for the plugin to see how it's done and use the code for your own scripts or modify the plugin itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.