3

I need to build a 100m buffer around a categorized polygon layer using QGIS 3.2.

The layer has four classes and no holes. The difficulty here is, that the buffer needs to be split into the 4 categories at the edges of the original polygons. Hard to explain in words, so I drew a quick sketch:

enter image description here

It doesnt have to follow a specific rule and it can be a multistep solution as well.

How can this be done using QGIS 3.2? And is there a special term for single sided buffers like this?

2

This sort of situation lends itself to a raster solution, then you can convert back to polygon. Conceptually, you are really buffering and then assigning the buffered area the nearest polygon value. So, breaking it down into steps:

1) perform a 100m buffer of all your polygons which will be used as a mask layer.

2) assign a numerical value to your polygon classes and convert the polygons to raster using the buffered mask layer to assign NoDATA to the area within the buffer area, but excluding the polygon (data) areas (simply using the buffer area as the output raster extent works too, if you were to assign values to all pixels within the extent and then clip to buffer later).

3) run the GDAL "Fill NoData" tool (aka "Nibble" tool in ESRI software).

4) convert your raster to polygons.

At this point you can joined based on class to get any extra attributes and erase and append/merge to get your original polygons into the output.

  • I'm more familiar with ESRI software but a quick google search indicated the name of the GDAL tool you need. Forgive me if that is incorrect. – RGfromRWBJV Jun 19 '19 at 16:38
  • Didn't expect such a solution, but indeed this works. However, using raster as workaround also has some disadvantages: for example if two neighbouring polygons have the value 1 and 3 the transition area will get values between 1 and 3, so also a - here not existing - class 2 will appear. And of course a raster will never be as smooth as a vector. However, many thanks for your working solution. Will accept it soon if noone has a solution using vectors only. – MrXsquared Jun 19 '19 at 17:47
  • Not so. If "Fill NoData" is truly analogous to Nibble. It it using the nearest neighbor value (NN) of the closest data (rasterized polygon cell), or perhaps there is an option in the tool to specify NN. So if you use the values 1,3,5,7 as your class values, only 1,3,5,7 will exist in the output. Also, you can smooth (generalize) the output when converting back to polygon. – RGfromRWBJV Jun 19 '19 at 19:24
  • Seems like it is not exactly the same. Seems like GDAL uses the next neighbouring classes by its distance and builds values between them based on this distance. Unfortunatly the documentation doesnt give a detailed explanation. Maybe my explanation was not very well: I use classes 1, 2, 3 and 4. The case I am talking about is, when polygons of classes 1 and 3 are neighbours, a class 2 is beeing built (values from 1.5 to 2.5 are in here) due to interpolation. So smoothing does not work here, as class 2 actually exists, but not at this location. – MrXsquared Jun 19 '19 at 19:42
  • Yes, you explained it well. It shouldn't be doing that. Are you specifying zero (default) on the smoothing in the Fill NoData tool? There should be no smoothing during the fill NoData process. I was referring to generalizing (what you called smoothing polygon outputs) during the raster to polygon process so that you don't have jagged grid-like polygon outputs. – RGfromRWBJV Jun 19 '19 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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