5

The problem

I have tens of thousands of small polygons for which I want to create buffer/doughnuts for, but I don’t get the units right. I want meters and not degrees, and changing to (what I think is) the right CRS my layer doesn’t longer show. The polygons are small farming plots. I work in QGIS 3.4.15.

Let me take you through it

I start by adding a vector layer. I opt for ‘Directory’ as a source type (Encoding: UTF-8 by default) and under Source (Type: UK. NTF2 by default) I point to the folder in which I store the shapefile.

The default CRS is set to EPSG:4326 – WGS 84, for both layer and the project (checked in bottom right), and unit is thus in degrees. I add the layer world map (EPSG:4326 – WGS 84 by default) by taping “world” in the coordinate box in the middle bottom, I also add Open street map (EPSG:3857 – WGS 84 / Pseudo-Mercator by default) from XYZ Tiles. The polygons appear nicely on the map considering some are just adjacent to the nearby lake, many nicely adjacent to roads, etc.

When attempting to do buffers the distance is obviously set to degrees. I have tried to change the CRS, both for the layer(s) and the projects, but without luck. After researching (e.g. here: https://epsg.io/?q=Kenya%20kind%3APROJCRS) I believe that the correct CSR would be Arc 1960 / UTM zone 36S EPSG:21036 (it is my understanding that either 36N or 36S would work as the polygons appear both south and north of, but close enough to the equator). When setting the mentioned CRS for my polygon layer, the polygons disappear from the map, and remain gone even after setting the project CSR (by bottom right) to the same. It seems that whenever I try with different CRS in UTM, the layer doesn’t show. Does this mean that the polygons are somehow not compatible with units in meter? Is there an issue with importing the .prj file?

Other things I've tried:

I have made a good attempt searching for solutions. I have ensured that the polygon layer is on top of the layers list. I have ensured the file names are identical and tried all different suitable CRS I can think of. I have seen similar questions been solved by saving the .shp 'as', but I don't think that's my issue as it's already a .shp file. Can it be the case that I need to perform a datum transformation? I gave it a shot using a transformation code (1122) provided by above link, but then the polygons were projected on the Antarctica on the world map, so obviously something went quite wrong...

Note that when I have changed to what I believe is the right CRS I can execute buffers in units of meters, however, they do not appear on the window…

0

2 Answers 2

16

Do not use "Set CRS" within layer properties. This does not reproject your data. You only define the CRS there. Means: you tell QGIS that the layer is in a different CRS than it actually is.

Instead:

Use "Export --> Save features as..." by rightclicking the desired layer in your layerpanel and choose your desired CRS over there. This does actually reproject your data. You need to save your data into a new file. This new file will then be in the chosen CRS.

Or alternatively, use "Reproject Layer" from processing toolbox. This tool can now be used as "Edit features in place" processing tool, so you do not necessarily have to create a new file: enter image description here

5

You can dynamically change the CRS that is used with QGIS expressions and the function transform(). In this way, you can use whatever CRS on any layer for calculations, geometry generation etc.

Let's say you have a point layer in EPSG:4326 (units:degrees) and project CRS also in EPSG:4326. If you set a "normal" buffer with buffer ($geometry, 70), you get a circle with radius 70 degrees: the red shape in the screenshot.

You now can set on the same layer an expression that creates buffers in another CRS, using meters as units. For demonstration purpose, I used EPSG:3857, even if that should not be used for measurements. The result is the blue shape. The expression used is:

transform (
    buffer (
        transform(
            $geometry, 
            'EPSG:4326', 
            'EPSG:3857'
        ), 
        10000000
    ),
    'EPSG:3857',
    'EPSG:4326'
)

enter image description here

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.