1

I want to smooth a polygon in QGIS. The smooth tool is not sufficient. I need much stronger smoothing. In the picture below you can see my current polygon after smoothing it with the QGIS smooth tool (red) and my desisred output produced in ArcGIS (blue).

Here are the parameters used in QGIS for smoothing:

smoothed = processing.run(
            "native:smoothgeometry", 
            {
                'INPUT':buffer_smooth,
                'ITERATIONS':10,
                'OFFSET':0.5,
                'MAX_ANGLE':180,
                'OUTPUT':'TEMPORARY_OUTPUT'
            }
        )['OUTPUT']

And here are the parameters I used in ArcGIS for smoothing:

if formula == "Fein":
    smooth_value = (0.25) * ((length / 1000)**(1/2.))

else:
    smooth_value = ((0.2) * ((length / 1000)**(1/2.)))**2

smoothed = arcpy.SmoothPolygon_cartography(buffer_smooth,r"in_memory\smooth", "PAEK", "%s Kilometers" % smooth_value)

The problem is that in QGIS the paramters (iterations, offset and max_angle) used for regulating smoothing are already set to maximum. Hence, I can not use the formula of my python code, because the smooth_value is bigger than 0.5 (maximum offset value).

enter image description here

3

1 Answer 1

3

While not core QGIS, there are other GISs that can be installed as plugins, which have their own smoothing algorithms that may work for you.

For example, Whitebox Tools plugin has SmoothVectors, which can be run with any size filter. The blue line is the QGIS smooth tool, and the red line is the Whitebox Tools smooth tool, with a filter size of 51. This looks reasonably similar to your example above. A filter size of 3 gives a result more like the QGIS smooth tool.

enter image description here

One catch with non-core tools in PyQGIS is that (unless it's been fixed recently) you need to define the temporary output explicitly. See QGIS Processing algorithm output for more information.

PyQGIS example code:

smoothed = processing.run(
            "wbt:SmoothVectors", 
            { 
              'filter' : 51, 
              'input' : buffer_smooth, 
              'output' : QgsProcessingUtils.generateTempFilename('example.shp') }
        )['output']

Other GISs with smoothing plugins include SAGA and GRASS.

0

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.