Skip to content
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

Single part to multipart yields multipart polygons with incorrect areas #22481

Closed
qgib opened this issue Mar 16, 2016 · 6 comments
Closed

Single part to multipart yields multipart polygons with incorrect areas #22481

qgib opened this issue Mar 16, 2016 · 6 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Processing Relating to QGIS Processing framework or individual Processing algorithms

Comments

@qgib
Copy link
Contributor

qgib commented Mar 16, 2016

Author Name: Mattias Lindman (Mattias Lindman)
Original Redmine Issue: 14508
Affected QGIS version: 2.12.3
Redmine category:processing/qgis


In a land cover study I want to derive the total area for each land cover type in a land cover layer (vector data). In order to do this I tried to use Vector/Geometry tools/Single part to Multipart in order to obtain an attribute table with one row per land cover type. By using the field calculator it should then be possible to derive the total area of each multipart land cover feature.

By comparing the obtained areas from the multipart layer with the sum of the single part areas for each land cover type in the original layer it turns out that there are quite significant differences, in the range 5-10 % for most land cover types. A visual comparison of the maultipart and the singlepart layer at a few locations does however not reveal any differences in the geometry that can explain the differences in the areal estimates.

In order to provide the possibility to reproduce the problem I attach an extract from the land cover layer containing individual shrubland polygons.

I have tested the singlepart to multipart conversion using both QGIS 2.8.7 and 2.12.3 and the problem is the same in both versions. I am running QGIS using Windows 8.


@qgib
Copy link
Contributor Author

qgib commented Mar 16, 2016

Author Name: Maximilian Krambach (Maximilian Krambach)


I tested your data and can see that the "multipart" output is indeed about 5-10% bigger than the input. Not just in area calculation, but also in geometry. It seems that some rings are filled that should not be filled. The pattern seems a bit random. Some (~10%) rings are filled correctly, most (~70%) incorrectly, and some (~20%) partially correct.

As a workaround, I suggest (vector-Analysis-Basic statistics) which outputs the statistics of a field (e.g. area) of all features in the layer.

In terms of code it seems that quite a few rings ("interiorRing") become parts("exteriorRing") somewhere during the operation. Could this be a memory issue, as they are all stored in one list (300.000+ vertices)? Or maybe some confusion between the first item of a polygon (exteriorRing) and the following (InteriorRing)?

@qgib
Copy link
Contributor Author

qgib commented Apr 14, 2016

Author Name: Giovanni Manghi (@gioman)


The layer has some errors, for example if I import the layer as singlepart in PostGIS and try to make a multipart version I get errors like:

GEOSUnaryUnion: TopologyException: Input geom 0 is invalid: Hole lies outside shell at or near point 1658834.9461550333 166634.78589000006 at 1658834.9461550333 166634.78589000006

If clean with ST_MakeValid during the singlepart to multipart phase then the operation goes ok.

So, if I:

  • import the layer to postgis as singlepart
  • clean it with ST_Makavalid
  • compute areas of any single feature (of cleaned singlepart layer) and sum by landuse
  • make a multipart version of the layer and compute the areas
  • compare

the differences are very small (down to the 5th decimal place)

but if compute the areas of the unclean singlepart version and compare to the cleaned multipart ones, then there are much bigger differences.


  • operating_system was changed from Windows 8 to

@qgib
Copy link
Contributor Author

qgib commented Apr 14, 2016

Author Name: Giovanni Manghi (@gioman)


the areas computed in the shapefile version of the cleaned (with postgis) singlepart vector are the same as the ones computed in postgis.

Then the areas for the multipart version of this shapefile (in this case the singlepart to multipart operation was done with the qgis tool) are not comparable to the ones computed in postgis, there are differences suggesting that even with a supposedly cleaned vector the singlepart to multipart tool does something not expected(?).

@qgib
Copy link
Contributor Author

qgib commented Apr 27, 2017

Author Name: Alexander Bruy (@alexbruy)


I think we can close this as error was caused by invalid geometries.


  • status_id was changed from Open to Feedback
  • category_id was changed from Geometry to Processing/QGIS

@qgib
Copy link
Contributor Author

qgib commented Apr 30, 2017

Author Name: Giovanni Manghi (@gioman)


  • easy_fix was configured as 0
  • regression was configured as 0

@qgib
Copy link
Contributor Author

qgib commented May 26, 2017

Author Name: Giovanni Manghi (@gioman)


  • resolution was changed from to invalid
  • status_id was changed from Feedback to Closed
  • description was changed from In a land cover study I want to derive the total area for each land cover type in a land cover layer (vector data). In order to do this I tried to use Vector/Geometry tools/Single part to Multipart in order to obtain an attribute table with one row per land cover type. By using the field calculator it should then be possible to derive the total area of each multipart land cover feature.

By comparing the obtained areas from the multipart layer with the sum of the single part areas for each land cover type in the original layer it turns out that there are quite significant differences, in the range 5-10 % for most land cover types. A visual comparison of the maultipart and the singlepart layer at a few locations does however not reveal any differences in the geometry that can explain the differences in the areal estimates.

In order to provide the possibility to reproduce the problem I attach an extract from the land cover layer containing individual shrubland polygons.

I have tested the singlepart to multipart conversion using both QGIS 2.8.7 and 2.12.3 and the problem is the same in both versions. I am running QGIS using Windows 8.
to In a land cover study I want to derive the total area for each land cover type in a land cover layer (vector data). In order to do this I tried to use Vector/Geometry tools/Single part to Multipart in order to obtain an attribute table with one row per land cover type. By using the field calculator it should then be possible to derive the total area of each multipart land cover feature.

By comparing the obtained areas from the multipart layer with the sum of the single part areas for each land cover type in the original layer it turns out that there are quite significant differences, in the range 5-10 % for most land cover types. A visual comparison of the maultipart and the singlepart layer at a few locations does however not reveal any differences in the geometry that can explain the differences in the areal estimates.

In order to provide the possibility to reproduce the problem I attach an extract from the land cover layer containing individual shrubland polygons.

I have tested the singlepart to multipart conversion using both QGIS 2.8.7 and 2.12.3 and the problem is the same in both versions. I am running QGIS using Windows 8.

@qgib qgib closed this as completed May 26, 2017
@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! Processing Relating to QGIS Processing framework or individual Processing algorithms labels May 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Processing Relating to QGIS Processing framework or individual Processing algorithms
Projects
None yet
Development

No branches or pull requests

1 participant