-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Lines to Polygon: output missing features when saving to SHP and input is multipart #47288
Comments
@Muesgen please test on 3.22.3, 3.18 is unsupported. Also add here all the details you have added on SE (where someone has left an answer with a clue of that could be the problem). |
I tested on 3.22.3 Version and the problem is still there. You can access the example data from my Google Drive in shapefile format: https://drive.google.com/drive/folders/1I_uhDnlvqjhrHZfUWmIpZoi-C5nDTG47?usp=sharing The lines are extracted from citygml file from this source: https://www.opengeodata.nrw.de/produkte/geobasis/3dg/lod2_gml/lod2_gml/LoD2_32_352_5662_1_NW.gml Python Console executed inside QGIS. 3.22.3
if I run the same algorithm with the interface, the result is correct: Here the recorded command from the protocol: The lines definitely meet, that I checked in the WKT format of the shape. On StackExchange there was an answer that the error happens when writing out the shapefile, because with GeoPackage there was no problem with writing out the correct geometry. Quote frome SE:
|
|
@gioman it
@gioman, while I agree it is unusual that the layer contains only 1 multipart feature geometry (MultiLineStringZ) with 9871 parts (most of them are also duplicates: only 4811 of them are unique geometries), it seems to me this is not the real cause of the issue. First of all, the "Lines to polygons" (qgis:linestopolygons) algorithm has code in place to supposedly correctly handle multipart (QgsGeometryCollection) geometries: QGIS/python/plugins/processing/algs/qgis/LinesToPolygons.py Lines 123 to 136 in bbfa18f
Second, there is an inconsistency: exporting to a Shapefile layer produces different results than exporting to a GeoPackage or a Memory layer. Moreover, as you have already find, if you convert ("Multipart to singleparts") the original layer to a layer with 9871 singleparts features, then you get the same results applying the "Lines to polygons" alg to this layer and exporting to both GeoPackage and Shapefile. Is it possible to replicate the issue using a subsets of the original data, which contain 1 multipart feature (MultiLineStringZ) with only 7 parts: Issue47288_Lines.zip Applying the "Lines to polygons" alg and exporting to a GeoPackage or a Memory layer (Issue47288_Polygons.gpkg in Issue47288_Polygons_GPKG.zip): Applying the "Lines to polygons" alg and exporting to a Shapefile layer (Issue47288_Polygons.shp in Issue47288_Polygons_SHP.zip):
I think the issue is related to the GDAL/OGR library which QGIS relies on to write and read Shapefile format layers or some limitation of the Shapefile format. Tested with QGIS 3.16.16, 3.22.3, 3.23.0 from OSGeo4W v2 (GDAL 3.4.1). |
@agiudiceandrea thanks for the analysis! I'm fine with the conclusions :) |
This may be eventually fixed by OSGeo/gdal#7157. |
The issue has been fixed in the GDAL/OGR library with PR OSGeo/gdal#7157: it will not occur using a GDAL/OGR release version >= 3.7.0. On Windows, official OSGeo4W stand-alone and network installers of QGIS 3.28.7 and QGIS 3.30.3 and later versions will use GDAL/OGR release version >= 3.7.0. |
Seems can be closed now as upstream issue was fixed. |
While the issue no longer occurs using the latest QGIS versions for Windows distributed by OSGeo4W (which currently ships GDAL 3.7.2), the issue still occurs e.g. using the latest QGIS versions for Ubuntu Lunar and Jammy (GDAL 3.4.1 and 3.6.2) and for Debian bookworm (GDAL 3.6.2). |
I'm aware of that. But upstream issue is fixed and we don't need to do anything on the QGIS side. How keeping this open will help users with old GDAL? |
What is the bug or the crash?
I have found a bug with the "lines to polygon" tool of QGIS and would like to know if the bug is known and if there is a workaround?
I want to convert my MultiLineString Z to MultiPolygon Z with Qgis inside a plugin. The results from the processor tool are different from the Python console than from the tool interface.
Polygons are missing in the layer created via the Python console, while all polygons are in the output via the interface. However, if I do not select a temporary output but a layer file to be written out, the polygon geometry is also missing via the interface .
Steps to reproduce the issue
See
Versions
QGIS 3.18 and Python 3.7
Supported QGIS version
New profile
Additional context
No response
The text was updated successfully, but these errors were encountered: