50

Is it possible to smooth or generalize a polygon in QGIS, perhaps by using a plugin like the Generalizer Plugin for lines?

I could convert my polygons to lines, smooth them and convert them back to polygons but this is not working for my polygons because of several reasons.

Taras
  • 32,823
  • 4
  • 66
  • 137
MartinMap
  • 8,262
  • 7
  • 50
  • 114

5 Answers5

39

You can use the "Simplify" geoalgorithm via:

Vector menu -> Geometry tools -> Simplify

simplify

Beside this you can use the Douglas-Peucker algorithm in PostGIS too, so you can use it PostGIS then adding the PostGIS layer to QGIS. you can find some info here about Simplify: Reduce the weight of a geometry.

SELECT simplify(the_geom, 500) AS simpgeom 
FROM neighborhoods

simplfy

Taras
  • 32,823
  • 4
  • 66
  • 137
urcm
  • 22,533
  • 4
  • 57
  • 109
  • 6
    That simplifies the lines, making them more jagged. Is there a way to smooth them(which I guess would have to interpolate some points)? – Nate Wessel Dec 23 '12 at 17:13
  • Simplify just removes vertices from the line or polygon, which can still leave jagged lines. You want the Generalizer plug in if you want smoothed lines. – MicheleTobias Aug 19 '14 at 02:48
  • 1
    For additional info, this tool has moved in QGIS 2.16 to the Processing toolbox / QGIS geoalgorithms / Vector geometry tools / Simplify geometry – gisnside Sep 09 '16 at 15:43
27

Aragon's answer is good for generalization. Bryan's answer is good for smoothing but is a little convoluted. Here are two alternatives for smoothing:

  • Use the GRASS v.generalize tool from the Processing toolbox. This is the module on which the QGIS Generalizer Plugin in Bryan's answer is built. The GRASS tool allows you to use polygons so you can avoid the steps of converting to lines and back again. It is an excellent tool with a LOT of algorithms for smoothing/generalization.
  • Use the 'old-school' approach of buffer-debuffer. Simply buffer your polygons by an appropriate amount (your call depending on the nature of the data and degree of smoothing you require). Then de-buffer by applying the same value for the buffer distance but making it negative this time. If you dissolve the buffers first time, you can often simultaneously eliminate small gaps or doughnut holes if required (though this is not always desirable so consider carefully before opting to dissolve).

Smoothing often means the addition of vertices (especially with the buffer-debuffer method). After smoothing, you could then apply generalization as per Aragon's reply.

Babel
  • 71,072
  • 14
  • 78
  • 208
MappaGnosis
  • 33,857
  • 2
  • 66
  • 129
17

I've also had luck using the QGIS Generalizer plugin (enable experimental plugins), and then:

Vector > Geometry Tools > Polygons to lines

Then use the Generalizer plugin to smooth the lines and vertices

Plugins > Generalizer > Generalizer
Algorithm: "Chaiken's Algorithm"

Then turn the lines back into a polygons

Vector > Geometry Tools > Polygons to lines

This does a better job actually smoothing the lines and rounding the corners. It's a bit clunky to have to have to switch back and forth between lines and polys, but it works. I know that there's ways to do this via Grass as well, but I've found them difficult to setup.

bryan kennedy
  • 281
  • 2
  • 5
  • This a useful approach: however, I had holes in my polygons and I cant recreate them with the lines->polygon tool – Djana Oct 11 '16 at 13:32
12

It is now available the Smooth geometry algorithm via Processing Toolbox > QGIS geoalgorithms > Vector Geometry Tools.

  1. Take jagged geometry objectsenter image description here
  2. Set options (I changed the Iterations field to 5 and was satisfied with the result)enter image description here
  3. Get smoothed object enter image description here
Mykola Kozyr
  • 752
  • 6
  • 11
  • Is the "smooth geometry algorithm" still a valid option? Since I do not get the desired results using other algorithms I was looking for this algorithm in my installation of QGIS 2.14 but could not find it. I then installed QGIS 2.18.16 but still can´t find this algorithm in the processing toolbar. I´d appreciate any help in finding or installing it. – Taya Jan 28 '18 at 14:29
  • 1
    Ok, Solution to my own problem found after restarting the system. There was a problem with the processing plugin right after the fresh installation of QGIS 2.18 was completed. Restarting the system and QGIS fixed this and I can see the "Smooth geometry algorithm" inside the processing toolbox. – Taya Jan 28 '18 at 17:50
  • I should check gisSE more often :) I'm glad you found the solution – Mykola Kozyr Jan 29 '18 at 08:03
  • I think you are missing a step... I have the French version for my QGIS install so I can't quite add the step myself but somewhere along the line I had to choose "lisser". – user3386170 Sep 18 '18 at 15:34
3

Right click on main board (on top) then activate "toolbox" -> see as you can see on pic below enter image description here

Soyol A
  • 51
  • 4