• Blog posts

    Bio

    By David Crowther

    QGIS___Aggregate_-_1.PNG

    Question:

    How can you group individual records into Multi-Part objects within QGIS?

    Answer:

    The Aggregate Tool within QGIS enables you to group individual records by a column value, to create a record with Multi-Part Objects.  

    In QGIS below I have a Polygon Layer showing Planning Applications. These each have a Progress value, of either – Passed, Submitted or Failed.

    QGIS___Aggregate_-_2.PNG

    We will use the Progress value to group the individual records into 3 Multi-Part object records.

    From the Processing menu choose > Toolbox > and open the Vector Geometry section.

    QGIS___Aggregate_-_3.PNG

    Choose the Aggregate menu option.

    QGIS___Aggregate_-_4.PNG

    The Aggregate Tool will open.

    QGIS___Aggregate_-_5.PNG

    We will use the following settings:

    • In the Input Layer choose the Planning Apps Layer.
    • In the Group by Expression choose the field to Group on > Progress
    • For each field in the Input Layer, you should choose what will happen when those values are aggregated e.g.
      • SUM the values for numerical fields e.g. the Area field.
      • Concatenate Textual input fields.
      • or use the First value for textual fields e.g. the Progress field.
    • Finally choose the output file, this could be a GIS file or a Temporary Layer that you can save a copy of later.

    QGIS___Aggregate_-_6.PNG

    If you now Run the Aggregate Tool, data dependent, you may encounter some possible errors. For example, if you have invalid geometry, the tool will notify you and you will need to either amend those records or you could ignore them.

    QGIS___Aggregate_-_7.PNG

    To ignore invalid geometry, you can choose the Settings button.

    QGIS___Aggregate_-_8.PNG

    and then choose the Skip (Ignore) option for Invalid feature filtering.

    QGIS___Aggregate_-_9.PNG

    Once the tool successfully runs, a new Temporary Aggregate Layer is created.

    It will now have grouped the individual records from the input layer (Planning Apps) by the chosen field (Progress). So, in the results table we now have just 3 Unique records – Passed, Submitted and Failed Planning Apps, and if we were to select one record, we now have Multi-Part Geometry connected to that record.

    QGIS___Aggregate_-_10.PNG