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.
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:
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).
$length
via the attribut table?$length
to calculate the total length.