# Split Polygons into Equal Parts using QGIS

In this post, I describe how we can use built-in QGIS processing tools to create a workflow to split polygons into equal parts. Using a clever algorithm and Feature Iterator tool in the Processing Framework, we can easily split all features in a given polygon layer into equal parts.

The algorithm for splitting any polygon shape into equal parts is described in this post PostGIS Polygon Splitting by Paul Ramsey. We will see how this can be implemented in QGIS.

## Get the Dataset

Want to follow along? Download the `cb_2019_us_state_500k.zip `file` `from` `Cartographic Boundary Files page of US Census Bureau website. Unzip and use the `tl_2019_us_state.shp`.

## Splitting a Single Polygon

Let’s say we want to split a single polygon into approximately 4 parts of equal area. Here we have the state of California in the US.

### 1. Create Random Points within the Polygon

Use the Random Points Inside Polygons tool from the Processing Toolbox to create random points. The more points the better, but for a polygon like this, we can use 1000 points.

### 2. Create Clusters

If you want to split the polygons into N parts, create N clusters. Here we want to create 4 equal parts, so we use the K-Means clustering tool from the Processing Toolbox to create 4 clusters.

### 3. Group Cluster Points

Now, use the Aggregate tool to group points from the same cluster and create multipoint geometries from all points belonging to the same cluster.

### 4. Calculate Cluster Centroids

We can use the Centroids algorithm to calculate the centroid of each multipoint feature.

### 5. Create Thiessen Polygons

We have centroids for each of the parts. Using the Thiessen Polygons (SAGA) algorithm, we can now create polygons that will divide the region so that each point within the region is assigned to the closest centroid. This will closely match the clusters we computed. The Frame Size parameter controls the buffer region. We can use the size of the bounding box of the polygon to determine the ideal buffer size. It should be at least half of the largest edge of the bounding box.

``framesize = max(maxy - miny ,  maxx - minx )/2``

We can also use the QGIS’s native Voronoi Polygons algorithm here, but if all the centroids are in a single line, it can fail to create thiessen polygons that cover the original geometry – even with a large buffer specified.

### 6. Clip Thiessen Polygons to Original Polygon Boundary

Using the Intersection tool, we can now overlay the thiessen polygons on the original polygon layer to split it into 4 equal parts.

The result is what we want. The original polygon split into 4 equal parts.

## Splitting Multiple Polygons

What if you want to split multiple polygons into equal parts? We can build a model to build a workflow of all the steps in the previous section and run it on each polygon. Below is the screenshot of a model built using the QGIS Processing Modeler. You can download and install this model from the Spatial Thoughts QGIS Resource Sharing repository.

Once installed, you can launch it from the Processing Toolbox. We will run it on a polygon layer containing of all states of the US.

When running the model, we want to split each polygon. Select the `tl_2019_us_state` layer as the Polygons layer and make sure to click the Iterate Feature button. Once configured, click Run.

Once the processing finishes, you will end up with 1 layer per state. Each layer contains the split polygons for that state.

The final step is to merge all these layers into a single layer containing all split polygons. We can use the Merge vector layers algorithm to accomplish this.

The result is the original US States layer split with 4 equal parts of each state.

There are a few existing QGIS plugins and methods that can also help with the polygon division task:

• Cadastral Divisions Plugin: If you are looking to split land parcels, this plugin can interactively help you find the correct divisions.
• Polygon Divider Plugin: If you are looking to divide a large polygon into many small regularly sized polygons, this is the plugin for you.
• Split Polygins using PyQGIS: A blog post by Luísa Lucchese showing how to use PyQGIS to split many polygons using a technique similar to this post.

Found this post useful? Do let me know in the comments!

If you want to learn and master techniques for automating your GIS workflows with QGIS and earn official QGIS.org certification, check out my course Advanced QGIS.

• Thanks for sharing! I checked it out and it works well. The use case seems to be more geared towards parcel splitting as it requires a reference line for direction in which to split the polygon. But it is definitely better to use this plugin for cadastre data. I have updated the blog post to include a link to it.

1. Stefano Campus says:

Thank you, Giulio will be happy!

2. Gus Polly says:

Instead of using Aggregate and then Centroids, you can just use Mean Coordinates with CLUSTER_ID as the unique ID field. And if SAGA isn’t working on your installation, the native “Voronoi polygons” algorithm does the same thing.

• The “Mean Coordinates” algorithm is a good suggestion and will save one step. Thanks!

I have mentioned the reason for using SAGA’s Thiessen Polygon algorithm in the post. “…QGIS’s native Voronoi Polygons algorithm here, but if all the centroids are in a single line, it can fail to create thiessen polygons that cover the original geometry – even with a large buffer specified…”

3. Hello, Mr. Ujaval Gandhi! This post is very helpful and was one of my inspirations for automatizing the polygon division procedure using PyQGIS. My pipeline differs from yours but the idea behind it is the same. I also linked your post in my blog post. Here is the link if you wish to check it out: https://www.luisalucchese.com/post/split-polygons-pyqgis/

• Thanks for sharing. I have added a link to your blog post as some readers may find it helpful to know how to implement this in PyQGIS.

4. suresh bishnoi says:

I have state shp/geojson file for a state but I need to make small modification in it like one particular district from it divided into two districts and I just need to draw approximate line to split that district. I tried http://geojson.io/ and https://mapshaper.org/ but could not do it.

5. Mika says:

Hi there!
I know it’s a long shot as this topic is quite old, but i’m losing my mind trying to replicate your process for splitting a polygon.
For some unknown reason i can’t get past Step 2… K-means clustering always create only 1 cluster. I tried with a bunch of different shapes, sizes, amounts of points, but nothing changes.
I’m very new to QGis but i can’t see what i’m missing.

If someone could help, it would save me from insanity ^^

6. Aashi says:

Hi there!
I have a similar irregular shapefile which i am trying to split into different polygons but my shapefile is discontinuous, Can you please help me out?

I am stuck with first step itself.

7. Isaiah says:

Hi Ujaval

This is a valuable resource for my work. However, I’ve encountered an issue when calculating the areas of the split polygons using the open field calculator.

Despite the expectation that the split polygons should be equal parts, I am noticing discrepancies in the calculated areas. The figures I’m getting are not consistent, and I’m trying to understand what could be causing this discrepancy. I’ve used the open field calculator for the calculations.

I would greatly appreciate it if you could provide some guidance on potential reasons for these variations in polygon areas. Your expertise in this matter would be immensely helpful.

Thank you for your time, and I look forward to hearing from you soon.

Isaiah

• This method based on k-means is based on random distribution of points and will genrate parts that are similar size but not exactly the same. If you want to split into parts of same area or parts having specific area – use one of the plugings mentions. The ‘Cadastral Divisions Plugin’ works well for that purpose.