Meters Vs Degrees: How To Force Qgis Buffer Tool To Use Metric Units

The Problem: Buffers Created in Degrees Instead of Meters

A common issue when working with geospatial data in QGIS is that distance and area calculations can unexpectedly be returned in geographic degrees instead of projected units like meters. This happens frequently when using the Buffer tool to create buffer zones around vector features.

For example, you may attempt to create a 100 meter buffer around a point, line, or polygon feature to analyze or select additional features within that distance. However, instead of a 100 meter buffer, the output is a buffer zone that covers a 0.008983 degree area. This occurs because the underlying coordinate reference system (CRS) of the data layer or QGIS project is in an unprojected geographic CRS using latitude and longitude values in degrees, instead of a projected CRS with linear units.

Dealing with unwanted degree-based buffers instead of the expected metric distances is frustrating for QGIS users who require metric measurement values for analysis tasks. The buffer outputs cannot be meaningfully measured or converted when in non-linear geographic degrees. Fortunately, QGIS offers full control and transformation capabilities make sure buffers calculations are performed in the desired metric units.

Understanding Coordinate Reference Systems in QGIS

To force metric buffer distances, it is important to first understand the coordinate reference system (CRS) concept in GIS software like QGIS. The CRS defines the translation between locations on the Earth’s surface and numeric coordinate values. It also determines the units and projections used to represent real-world distances and areas.

There are two broad categories of CRS:

  • Geographic CRS – Based on a spheroidal model of the Earth, with coordinates defined in latitude and longitude degrees. Distances and areas will be in decimal degrees, not linear units like meters.
  • Projected CRS – Projects geographic coordinates onto a 2D planar surface, allowing use of linear units like meters. Provides accurate real-world distances, areas, and shapes for mapping and analysis within the projection zone.

QGIS layers can have an associated CRS defining the coordinate system. When data layers with different CRSs are visualized or analyzed together, QGIS performs “on-the-fly” transformation between CRSs behind the scenes in most cases. This allows seamless mixing of data – but can also lead to unprojected analyses if geographic and projected data are combined without explicit transformation instructions.

Setting the Project CRS to a Metric System

The first step to ensure metric buffer distances is to set an appropriate projected coordinate reference system (CRS) at the QGIS project level. This avoids “on-the-fly” geographic CRS transformations for any analyses within this project.

To define the project CRS:

  1. In the QGIS browser panel, right-click on the project name and select Properties.
  2. In the Properties dialog, click on the CRS tab.
  3. Under the Coordinate reference systems of the world section, expand the Projected CRS > UTM node.
  4. Select the desired UTM zone for your project area. For example, WGS 84 / UTM zone 15N.
  5. Click OK to set the selected CRS as the project’s reference system.

The project now has an explicitly defined metric coordinate system. Any geospatial calculations done within this project will be in meters rather than unprojected geographic degrees. This avoids unwanted degree-based outputs for buffer zones or other geometries created with the project’s layers.

Using the On-the-Fly CRS Transformation

In some workflows, setting the underlying project CRS may not be possible or desirable. In these cases, the on-the-fly coordinate transformation tool can be used to define layer-level projections to enable metric distance calculations.

To use on-they-fly transformation:

  1. In the Layers panel, right-click on the layer to buffer and select Properties.
  2. In the Properties dialog, switch to the Source tab.
  3. Expand the Coordinate reference system section.
  4. Enable the On the fly CRS transformation option.
  5. In the Filter text box, search for a metric projected CRS appropriate for the layer’s geographic location, such as UTM.
  6. Select the desired CRS. A globe icon indicates it is a projected metric CRS.
  7. Click OK to apply the layer CRS transformation.

With on-the-fly transformation enabled, projections to the metric target CRS will now automatically occur whenever this layer is analyzed. Any buffer distances calculated will use the linear units defined in the metric CRS instead of unprojected degrees.

Creating Metric Buffers with Python Code

Using Python scripting in QGIS is a flexible approach to force metric units on buffer operations. Custom Python code can explicitly define the desired metric CRS and output format for geometry calculations.

For example, this script projects input layers to UTM before buffering, and formats the output distances in meters:

layer = qgis.utils.iface.activeLayer()
layer_crs = 

utm_crs = 'EPSG:32615'

buffered_layer ="native:buffer", 
    {'INPUT': QgsProcessingFeatureSourceDefinition(, True, utm_crs, {}),
     'DISTANCE': 100, 
     'SEGMENTS': 5,
     'END_CAP_STYLE': 0,   
     'JOIN_STYLE': 0,
     'MITER_LIMIT': 2,
     'DISSOLVE': False,
     'OUTPUT': 'memory:'}) 
format_string = '{:.3f} meters'   

buffered_layer.dataProvider().addAttributes([QgsField('distance', QVariant.Double, 'double', 24, 15, format_string)])

meters_100 = float(format_string.strip(' meters'))

for feature in buffered_layer.getFeatures():
    buffered_geometry = feature.geometry()
        round(buffered_geometry.length(), 3))

The key steps are:

  1. Define desired metric CRS (UTM zone)
  2. Use this CRS in Buffer tool parameters
  3. Format output to show metric units

The output buffer layer’s distances will now be calculated and displayed in the defined meters units.

Verifying Buffers are Now in Meters

Once project CRS settings, on-the-fly transformations, or Python scripts are implemented to enable metric buffers, the results should be verified to validate correct distances.

To check that buffers are being calculated in meters:

  1. Add an identifiable point, line, or polygon feature to visualize (or use existing layer).
  2. Apply a buffer operation with a defined metric distance eg 100 meters.
  3. Inspect buffer result geometry to confirm it matches expected size and shape at defined distance.
  4. Optionally add metro grid or other reference data in meters to visually verify buffer dimensions.
  5. For additional validation, export the output buffer layer and check coordinate values in GIS or text editor.

Pay attention to buffer width, arcs, and corners during visual inspection, as these aspects will clearly show if an unprojected degree-based buffer was created instead of the expected metric distances.

Automated testing using PyQGIS could also be implemented to validate buffer output geometry against expected metric measurements.

Additional Tips for Managing CRS in QGIS

Utilizing the various CRS capabilities in QGIS is key to getting reliable and expected outputs from geospatial analyses.

Here are some additional tips for handling CRS transformations:

  • Always analyze vector data in a projected CRS, don’t use unprojected latitude/longitude degrees.
  • Set the project CRS to control analysis coordinate space.
  • Use on-the-fly reprojection for individual layers if needed.
  • Enable “on-the-fly” transformations with care as they may hide latent unprojected geospatial calculations.
  • Label key layers with their native CRS for reference.
  • Save analysis result layers with relevant CRS to avoid later confusion.
  • Use Python scripts for advanced control of CRS handling and conversions.

Following best practices for coordinate reference system management will help avoid unwanted degree-based measurements and facilitate accurate, metric-based geospatial analysis in QGIS.

Leave a Reply

Your email address will not be published. Required fields are marked *