By David Crowther
How can I extract geometry attributes from my layers using QGIS?
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.
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.
From the Processing menu, choose Toolbox and search for ‘Add Geometry’.
From the Vector Geometry tools choose Add geometry attributes and a new window will open.
- 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.
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.
If our input layer was a Polyline Layer, then the Add geometry attributes tool will extract the line length for each record.
Finally, if our input layer was a Point Layer, then the Add geometry attributes tool will extract the X & Y coordinates for each record.
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!