6

I buffered some lines with 100 m in QGIS. When I measured it turns out instead of 100 m its 62. I understand the issue could relate to the CRS. I used EPSG 3857 because the OSM map in the background uses this one too.

But what is wrong with the buffering done by QGIS and my CRS?

enter image description here

4
  • So I transfer my line layer in UTM and still keep EPSG 3857 for the project itself? Because if I change that too to UTM the OSM map will be effected.
    – BAE_23
    Aug 21, 2022 at 11:48
  • Does this apply also to length measurements via $length via the attribut table?
    – BAE_23
    Aug 21, 2022 at 11:49
  • apparently it is the same. My lines in EPSG 3857 have the same length as in UTM 32 N. When I use $length to calculate the total length.
    – BAE_23
    Aug 21, 2022 at 11:58
  • See my answer (last part) for this
    – Babel
    Aug 21, 2022 at 13:30

1 Answer 1

13

Measurements in EPSG:3857 are always wrong. To create correct buffer sizes and thus to cope with the problem, there are different ways - depending on your use case:

  • In your case (small buffer size), I propose solution 1: create a layer in a local CRS, appropriate for measurements.
  • For large buffer sizes (larger than area local CRS is valid), see solution 2: create geodesic buffers.
  • Solution 3 is an option of solution 1: using QGIS expressions on a layer in any CRS without the need to reproject your layer: calculate the buffer in another, local CRS that is appropriate for the task and transform the resulting buffer back to the initial CRS.

1. Create lines with layer CRS apt for measurements in region of interest

The easiest solution - as long as distances are not too large:

Create a layer in a CRS apt for measurement in your region of interest, e.g. local UTM zone. For your area (Landkreis Harz, as can be seen on your screenshot), use UTM zone 32 North / WGS 84- EPSG:32632 as layer CRS. Then, measurements will be correct.

You can still have your OSM basemap in the background, don't worry. QGIS will handle this for you automatically. See here for details to understand the difference between layer and project CRS.

enter image description here

2. Create geodesic buffers

The solution above works for for small distances. For buffers with larger distances, like on a continental scale, you should consider creating geodesic buffers. See here for how to do so in QGIS with this easy tutorial: Approximating Geodesic Buffers with PyQGIS.

3. Use QGIS expressions to transform CRS and create buffers at once

When using QGIS expressions, you can also transform inside the expression to overcome the difficulties of layer CRS. See here for details. Use with Geoemtry generator or Geometry by expression (see here for differences).

So you can even use a line layer in EPSG:3857 and create corectly sized buffers (calculated in another CRS) with this expression:

transform (
    buffer (
    transform (
        $geometry, 
        'EPSG:3857',
        'EPSG:32632'),  -- replace here if calculation should be done in another CRS
        100
    ),
    'EPSG:32632', -- replace here if calculation should be done in another CRS
    'EPSG:3857'
)

Red: corretly sized buffers on a line in EPSG:3857, created with the expression from above (transformed to EPSG:36232). Blue: buffer without transformation: enter image description here


What to be aware of

Consider also the difference between cartesian (planar) and ellipsoidal measurements. See here for details. Ellipsoidal measurements should return always the same value, indifferent of CRS (at least as long as they use the same ellipsoid). The other way round, the difference between cartesian and ellipsoidal measurements is an indication of the distortion resulting form the projection you use. If both values are more or less the same, you have a CRS with low distortion (at least at the scale and extent/region of interest you use).

2
  • 2
    Great answer, but I would suggest using CRS 36232 based on WGS 84 rather than 32232 based on WGS 72.
    – Szym
    Aug 21, 2022 at 17:18
  • Thanks for drawing my attention to this , I updated the answer accordingly. 32632 instead of 36232, in fact.
    – Babel
    Aug 21, 2022 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.