## Add Geometry Attributes (Length, Area, Perimeter) or X / Y Coordinates to Shapefiles in QGIS

Before adding geometry attributes (length, area, perimeter) to a line or polygon shapefile or X / Y Coordinates to a point shapefiles in QGIS, make sure the shapefiles are in reference to a projected coordinate system such as a UTM Zone, or a State Plane Coordinate System (Refer to this post for the differences between a **projected coordinate system** and a **geographic coordinate system**).

- To add X, Y coordinates to a point shapefile, select the point shapefile in the
**layers panel**to make it current:

- Click top menu of
**Vector**, select**Geometry Tools**and then**Add Geometry Attributes…**(). Type in a new point shapefile name, set “*Figure 1***Calculate using**” as**Layer CRS**, and click**Run**.

- Open the attribute table of the newly created point shapefile (
) to verify that X, Y coordinates of each point in reference to the layer’s CRS have been added. In this demo, the CRS is EPSG 2278 (Texas State Plane Coordinate System, South Central Zone, Unit: Survey Foot), so the unit of X, Y coordinates is survey foot.*Figure 2*

- To add length to a line shapefile or area & perimeter to a polygon shapefile, follow the same procedures of Step 1 above by clicking
**Vector –> Geometry Tools –> Add Geometry Attributes…**(and*Figure 3*). In this demo, the CRS is EPSG 2278 (Texas State Plane Coordinate System, South Central Zone, Datum NAD83, Unit: Survey Foot), so the unit of length and perimeter is survey foot and the unit of area is square survey foot.*Figure 4*

- Another way to add length, area, or perimeter to a shapefile attribute table is to use field calculator. Select a line or a polygon shapefile in the
**layers panel**to make it current and then open the field calculator:

- Check on Create a new field and provide a name for the output field name and field type – decimal number (real).
- for length, type in or search the expression of $length (
); for area, type in or search the expression of $area, and for perimeter, type in or search the express of $perimeter.*Figure 5* - Open the attribute table of (
and*Figure 6**Figure 7***Length_2**,**Area_2**,**Perim_2**).

- As shown in
and*Figure 6*, when using field calculator to calculate length, area, or perimeter, the results are in reference to the unit of ellipsoids. In the demo, since EPSG 2278 is based on Datum of NAD83 and Ellipsoid GRS80 which has unit of meter, the results are in meter or square meter. Ellipsoid GRS80 unit of meter is different from the projected coordinate system of EPSG2278 which has unit of survey foot.*Figure 7*

- The added geometry attributes are not dynamically linked to the features themselves. So if a feature is revised or edited, its geometry attributes will not be updated automatically and you will have to repeat the above steps to get new values.

## Leave a Reply