Bug report #4189
Simplify feature and Simplify geometries gives incorrect result on valid polygon
|Affected QGIS version:||master||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||Yes||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||14164|
It is impossible to simplify some polygons using QGIS.
When I tried to simplify polygon using Simplify geometries from fTools, polygon was simplified from 825 vertices to 0 and disappears. When I try to simplify this same polygon using Simplify feature tool from Advanced digitizing toolbar I get error "This feature cannot be simplified. Check if feature has enough vertices to be simplified.".
Check geometry says that there are no errors and polygon is valid.
Test shapefile attached.
#1 Updated by Maxim Dubinin over 8 years ago
The reason for wrong behavior is a tiny ring. If it is removed, the polygon is simplified ok.
The polygons with bigger rings simplify ok, but if any polygon has a ring that is smaller than tolerance, it breaks the whole polygon.
I think this is a bug, not sure though if GEOS or QGIS is guilty.
#4 Updated by Pieter Roggemans over 7 years ago
- File Simplify_problem.zip added
Same problem... If you do a simplify with 2 meter tolerance on the file in attachment one of the two polygons will disappear.Remarks:
- saying that "Causes crash of corruption = No" is kind of odd... as it definitely corrupts data: it was only by luck that I saw some polygons just disappeared... If I wouldn't have noticed, my analysis would have been quite corrupted :-(...
- I don't know which libraries are used for this opertation, but I tested it using ogr2ogr version 1.9 and then the simplify works perfectly...
#8 Updated by Salvatore Larosa over 7 years ago
I confirm this is only a QGIS bug in QgsGeometry::simplify() function!
Same thing for QgsGeometryAnalyzer::simplify()
We need to fix it in core!
OGR and GEOS (ST_Simplify()) work fine!
The only strange thing is that GEOS eliminates the small ring,
instead in OGR it remains as the original layer w/out any change!
#9 Updated by Pieter Roggemans over 7 years ago
In my humble opinion... I think the GEOS ways (removing too small rings) is the most logical one...
If you want to eliminate detail... you know you always loose data in a way, so I think it is more logical to remove the too detailed rings as well...
Eg. If you have a very detailed file you want to show at a low scale, it wouldn't be logical the outer rings are simplified, but there still stay very high-detail (sub)polygons simply because they are that small/detailed...
It implicates that you can loose features as well (if the outer ring is too detailed... but the logic holds here as well... removing details can result in loosing detailed features all together...
The choice is also an option of course... but that's the hard way for implementing and not quite KISS I admit ;-)...