Bug report #18606
QGIS 3.0 unable to extract vertices from polygons with inner hole
|Affected QGIS version:||3.0.0||Regression?:||Yes|
|Operating System:||Windows||Easy fix?:||Yes|
|Pull Request or Patch supplied:||No||Resolution:||invalid|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||26494|
I created a vector by polygonizing a raster with 40x40 meter cell size. The coordinates of the cell boundaries in the raster are exact multiples of 40 m. The conversion to polygon was carried out in both QGIS 2.18 and 3.0 (2.18.18 and 3.0.1 to be precize). The QGIS versions use the same routine to convert from raster to poygon, gdal_polygonize.py, with the same version: $Id: gdal_polygonize.py 36130 2016-11-06 15:51:48Z rouault $
The vectors generated by both versions are exactly the same, which was confirmed through a binary compirison of the shape files. I continued to work with the shape generated by QGIS v 3.0.
Adding the geometry columns to the vector works good in 2.18, for all polygons in the vector. Adding geometry in 3.0 fails, however, for a number of polygons. These polygons all appeared to have one or more inner holes. (Though there were also polygons with holes for which 3.0 did succeed to add the geometry) To find what's is going wrong in 3.0, I selected one of the simplest polygons for which 3.0 could not add the geometry and saved it as Select_1.shp. See attatched Select_1.jpg.
In 2.18 I extracted the vertices of Select_1 (with Vector - Geometry tools - Extract vertices), giving Nodes_1. Exporting the coordinates (Vector - Geometry tools - Extract Geometry columns) gives Nodes_1_geo.
Reading the dbf of the last shape the vertices of the polygon are correct: still exact multiples of 40 m.
It appears that QGIS 3.0 is unable to extract the vertices from Select_1.shp, error message
'Feature (0) has invalid geometry and has been skipped. Please fix the geometry or change the Processing setting to the "Ignore invalid input features" option.'
The shape files for the vectors Select_1, Nodes_1 and Nodes_1_geo are in the attached Vectors.zip.
#1 Updated by Nyall Dawson over 4 years ago
- Resolution set to invalid
- Status changed from Open to Closed
This is expected behaviour - the generated polygons aren't technically valid, and the default Processing setting is to halt execution when an invalid geometry is encountered (hence the "Feature (0) has invalid geometry and has been skipped. Please fix the geometry or change the Processing setting to the "Ignore invalid input features" option." error).
Check the Processing options, General, "Invalid Features Filtering" setting. Or run the "fix geometries" algorithm on the layer.