• Blog posts

    Bio

    By David Crowther

    QGIS___Extract_Geometry_Attributes_-_1.PNG

    Question:

    How can I extract geometry attributes from my layers using QGIS?

    Answer:

    In QGIS, you can use the Field Calculator from the Attribute Table to undertake column updates, including extracting the AREA of objects in your spatial layer.

    QGIS___Extract_Geometry_Attributes_-_2.PNG

    This is great, but it relies on you knowing which function to choose and it only allows you to run one update at a time.

    A faster way to do this is using the Processing tool > Add Geometry Attributes.

    In the example below we have a layer containing postcode boundaries in Exeter.

    QGIS___Extract_Geometry_Attributes_-_3.PNG

    From the Processing menu, choose Toolbox and search for ‘Add Geometry’.

    QGIS___Extract_Geometry_Attributes_-_4.PNG

    From the Vector Geometry tools choose Add geometry attributes and a new window will open.

    QGIS___Extract_Geometry_Attributes_-_5.PNG

    • Choose the Input Layer – to be the Exeter Postcodes.
    • Calculate using – the Layer CRS e.g. BNG 27700.
    • Output to – create a temporary layer.

    Press Run and the tool will create a copy of the input polygon layer and then (dependent on the geometry type) it will extract the geometry values for each record, in this case the Area and Perimeter.

    QGIS___Extract_Geometry_Attributes_-_6.PNG

    If we now re-order the output table on the Area field, we can select that record and as shown in the map, this is the postcode with the largest geographic area.

    QGIS___Extract_Geometry_Attributes_-_7.PNG

    If our input layer was a Polyline Layer, then the Add geometry attributes tool will extract the line length for each record.

    QGIS___Extract_Geometry_Attributes_-_8.PNG

    Finally, if our input layer was a Point Layer, then the Add geometry attributes tool will extract the X & Y coordinates for each record.

    QGIS___Extract_Geometry_Attributes_-_9.PNG

    This is a therefore a very useful tool for extracting geometry values for records in your Point, Line and Polygon layers, without having to run individual column updates one by one!