4

I wanted and I have tried in many ways to reproduce the "aggregate polygons" function from ArcGIS to QGIS.

I have an input with different types of parcels intersected. enter image description here

The parcels must be aggregated within a specified distance and area, as in ArcGIS case function looks like this: enter image description here

The output from ArcGIS looking like this, basically dissolving parcels within that aggregation distance and area. enter image description here

I have tried buffering the result with the specified aggregation distance and dissolving it, after that buffering it again with the same value but negative and making the output single parts. The shape of parcels it does not maintain it's identical form.

My second try was dissolving the input, making it multipart to single parts and buffering it with only 0,5 meters and cosmeticizing the result by deleting some holes/gaps generated only in QGIS in the dissolve part.

My QGIS output looking like this: enter image description here

The brown shapefile is is QGIS output generated by me and in the background (with green) is the correct ArcGIS output. As it is seen I didn't manage to realize it one to one, buffering with a higher value doesn't work because is dissolving other polygons that are not necessary.

I know there is an aggregate function in QGIS that groups polygons by Attribute values, but I do not know how to use it and what expressions to use to aggregate polygons within the distance of 4 meters and a minimum area of 30 square meters.

Is there any way to create the output identical?

5
  • Please decide about the software, otherwise you question can be closed
    – Taras
    Jul 19, 2021 at 7:18
  • 3
    I want to produce the output on QGIS. Jul 19, 2021 at 7:19
  • Do you want the space between close polygons filled? or do you just want them to become multi-parts? Jul 19, 2021 at 10:56
  • Yes, those green gaps needs to be filled and dissolved into the polygons that touch each other. I managed by buffering with 0.5 meters, to fill some of the gaps but if I give a bigger buffer it will merge with other polygons that are not intended. Jul 19, 2021 at 12:07
  • Can you share a sample of your data (input + desired output/the result from ArcGIS) to test possible solutions in QGIS?
    – Babel
    Aug 12, 2021 at 14:21

2 Answers 2

1

This is a long solution that may produce your desired results, but it may have some caveats. If your data is big I strongly recommend you test this on a small sample of your data first. I am going to name the layers for clarification.

  1. First you need to buffer shapes based on the threshold distance you want, let us say 5 meters.
  2. Then you need to dissolve without specifying a field so shapes get merged together.
  3. convert the dissolved shapes to single parts (call the layer BUFF-DIS).
  4. dissolve the original file and convert overlapping and adjacent shapes to a single shape (we need this so don't remove it, name it MASK).
  5. Now clip the BUFF-DIS with the MASK.

We now have multipart features of shapes that are supposed to merge together and let's call it MULT-AGG. what we need now is to fill the gaps. From this point, results may not be as good as ArcGIS, but they might suffice for your use.

Now make sure there is a field with a unique ID for each multipart shape as we need it later. If you do not have it use the field calculator to generate an ID field running this expression:

 @row_number 

Now we are set for the second stage:

  1. First use the boundary tool to convert your polygons to lines.
  2. Then use Explode lines on boundaries so each edge becomes a single straight line.
  3. Then use the centroid to get the center of each line.
  4. use Concave hull (k-nearest neighbor) on the centroids with the number of neighbors set to 2 or 3, and specify the field to the unique ID that we generated.

This should give you a rough shape that covers the gaps. The last step is to merge and dissolve this result with MULT-AGG so you will have an aggregated polygon.

I advise you to create a model that does all this stuff. hope this helps.

1
  • I have tried to create a model with the series of functions that you mentioned. The problem is that the concave hulls are generated on every polygon. Merging the result does not take the polygons within a specified distance. As is presented in last image the green polygons represent the "gaps" that must be covered and dissolved into the brown polygons the distance of that gap being under 4 meters, in rest every concave hull generated is not needed for the dissolve. Jul 21, 2021 at 12:47
1

It is not in QGIS, but if you can run python scripts you could try the (new) dissolve_within_distance feature of geofileops.

It offers a basic subset of features of "aggregate polygons". E.g. there is no option to specify the minimum area. Nonetheless it might be of use for use cases like in this question.

import logging
import geofileops as gfo

if __name__ == "__main__":
    # Init logging so progress printed by gfo is shown
    logging.basicConfig(level=logging.INFO)

    parcels_path = "/path/you/like/parcels.gpkg"
    output_path = "/path/you/like/parcels_dissolved.gpkg"
    gfo.dissolve_within_distance(
        input_path=parcels_path, output_path=output_path, distance=4
    )

Disclaimer: I am the developer of geofileops.

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.