4

I have this selected rectangular polygon in yellow on a layer with hundreds of polygons:

enter image description here

I need to split the selected polygon in 4 vertical columns (Y axis) and 8 horizontal rows (X axis), so that I get 32 final same-sized polygons. Something like this should be the output:

enter image description here

I have tested these plugins with no success so far:

  • Polygon Divider
  • Polygon Splitter
  • Split Polygon
  • Split Features on steroids

EDITED 19.12.2018:

Well in fact I have a layer with hundreds of polygons. It is my town's graveyard and it is divided in zones: enter image description here

I need to split some of them in smaller tiles (real graves, pantheons, etc) so that I can locate each buried person in his parcel (tile).

In the above image I showed three zones. Polygon 1: has to be split in 1(columns)x 40(rows) so there would be finally 40 polygons (graves).

Polygon 2: has to be split in 2(columns)x 50(rows) so there would be finally 100 polygons (graves).

Polygon 3: has to be split in 2(columns)x 3(rows) so there would be finally 6 polygons (graves).

All the polygons that need to be split have square-rectangle shape; only 4 sides.

EDIT 20.12.2018:

Array of offset (parallel) lines tool is not working well in my case. Seems that rectangles are not perfect (horizontal sides do not have exact same length, same with vertical). See image below:

enter image description here

7
  • @Taras Yes. The first one (Polygon Divider) online splits polygon by area (m2, etc) which in my case is not a known number and it also changes the whole layer and not selected object only. I need to go one by one, some will be 13x6 others 4x4, others 5x4, etc... In the second post you reference the Vector|Research Tools|Vector grid tool also creates squares by length (in meters or whatever)...
    – Egidi
    Dec 18, 2018 at 12:44
  • 2
    @Egidi: When you say the area is not known, you do realise that it is a function of the geometry and therefore always known (or accessible)? When you say you need to go one-by-one is this because the division is based on some other factor specific to a particular polygon and not a function of geometry? Can you give a little more information why these other tools won't work for you (otherwise people won't know where to direct you for your specific use-case) Dec 18, 2018 at 18:00
  • that's more doable with math; like X1 = Xmin; X2= Xmin + (Xmax - Xmin/4) ... and so on for Y; then you make polygons out of those points; for not north-south oriented you would use a little bit of trigonometry. In R should be easily done.
    – Elio Diaz
    Dec 19, 2018 at 3:14
  • Do you also have some irregular shaped polygons? can you give and example how these should be splitted? How do you select into how many parts the polygon will be splitted? In the example picture you said that it needs to be 4x8, why 4x8? Whats the criteria of how many parts there must be?
    – RistoYlem
    Dec 19, 2018 at 7:06

2 Answers 2

4

I went through a relatively convoluted way of doing it without having to script anything in Python or without having to resort to plugins. It's still semi-manual and includes some nested expressions but it works. Bear in mind this was done in QGIS 3.4. Some features used might not be available in earlier versions. To further automate the process, it could be made into a processing model.

First off, this method takes a few things for granted:

  • Layer is in a projected CRS
  • Zone polygons need to be "perfect" rectangles
  • Each zone polygon needs two fields where the number of divisions for each axis is present

The original data I used looks like this:

enter image description here

From there, a sequence of tools can be used to go from the original zones to subdivided plots (every tool takes as input layer the output of the previous tool):

  • Using the Polygons to lines tool, transform your zones into polylines.
  • Using the Explode lines tool, break each side into separate segments.
  • Using the Extract by expression tool, get only the two first segments of a rectangle with this expression (it tests for an array of only first and second segments of exploded sides):

    array_intersect(array($id), array_cat(generate_series(1, maximum($id) - 2, 4), generate_series(2, maximum($id) - 2, 4)))
    
  • Using the Field calculator tool, create a new field (in my case called len_seg) of type float where $length is calculated

  • Using the Array of offset (parallel) lines tool, create the plot subdivision lines with these expressions in the relevant parameters (it's convenient that the segments' right side is always inside the original polygon. I had to round the segment lengths before evaluating them as it seems there might be slight differences between opposite sides even for 'perfect' rectangles):

    Number of features to create:

    if(round("len_seg",3) = minimum(round("len_seg",3),group_by:="fid"),"plot_max"-1,"plot_min"-1)
    

    Offset step distance:

    if(round("len_seg",3) = minimum(round("len_seg",3),group_by:="fid"),(maximum("len_seg",group_by:="fid")/"plot_max")*-1, (minimum("len_seg",group_by:="fid")/"plot_min")*-1)
    
  • After this, you'll end up with a large number of offset lines layers. Using the Merge vector layers tool, combine the initial exploded segments and offset lines into one layer.
  • Using the Extend lines tool, add a small value (I added 0.02 in my example) to the plot lines. This ensures angled rectangles have complete polygon rings for the last step.
  • Using the Polygonize tool, convert that merged layer into polygons.

The result looks like this:

enter image description here

3
  • thanks for your answer. I updated the OP. Tested your method. Parallel lines not working well in my case...
    – Egidi
    Dec 20, 2018 at 10:34
  • @Egidi In light of your update, if your polygons aren't perfect rectangles, I really struggle to see how your question can be resolved. Is it by design that they are irregular or is it simply that no care was taken to draw perfect rectangles when the layer was first made? If it's the latter, maybe consider redrawing the rectangles?
    – Gabriel
    Dec 20, 2018 at 13:32
  • @Gabrield C. The draftsman did not tkae care when he drew it several years ago...Redrawing it for the moment I see it quite difficult. Thanks for your help!
    – Egidi
    Dec 20, 2018 at 13:59
0

Since you want to repeat the result of the draftsman, proceed as follows:

1) enter the "Pencil" editing mode;

2) Select the source polygon with the "Select Objects" tool;

3) Next, on the toolbar, select the Split Features tool and split the selected rectangle as a draftsman into the required number of subpolygons ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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