Bug report #5332

Wrong Area for large polygons in vector/Geometry Tools/Export/Add Geometry Columns

Added by alobo - about 12 years ago. Updated about 12 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:-
Affected QGIS version:1.7.4 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:duplicate
Crashes QGIS or corrupts data:No Copied to github as #:15033

Description

Results for large polygons are wrong when calculated with vector/Geometry Tools/Export/Add Geometry Columns
Example in
http://dl.dropbox.com/u/3180464/BorneoLCv2google.zip

Check, for example, polygons with ID 25967 and 26570: according to the table,
the areas are
25967: 8550196769
26570: 1736474738

while visual inspection indicates that 26570 is obviously much larger.

Both results are different than those calculated by R:

25967: 9294889613
26570: 205414657947

Discrepancies with R are particularly large for polygons with area > 1E+10

qgis 1.7.4 on ubuntu 10.04 32bits

This might be related to issue #4955

Agus

History

#1 Updated by Giovanni Manghi about 12 years ago

I don't think that this is related to #4955 because that issue is different: if the column is not wide enough the value is cut at the end (and there are no differences between the values computed by the field calculator and the "add geometry columns" tool), in this case the values are completely different.

#2 Updated by Giovanni Manghi about 12 years ago

  • Status changed from Open to Feedback
  • Priority changed from 6 to Normal
  • Operating System deleted (ubuntu 10.04)

After all the two issues are not that unrelated.

If you compute areas with the field calculator in a enough wide field, then the values make sense

ID Area_FC
25967 8550196769.93
26570 173647473841.47

Now I can't understand why values computed with R are so different. In QGIS it was used the layer CRS to make such counts, and in R?

#3 Updated by Giovanni Manghi about 12 years ago

Giovanni Manghi wrote:

After all the two issues are not that unrelated.

If you compute areas with the field calculator in a enough wide field, then the values make sense

ID Area_FC
25967 8550196769.93
26570 173647473841.47

the same values are computed by postgis.

#4 Updated by Giovanni Manghi about 12 years ago

the same values are computed by postgis.

so I would try to understand why values computed with R are different and eventually close this as duplicate.

#5 Updated by alobo - about 12 years ago

ok, it seems there are 2 issues here:
1. The wrong results I get with
vector/Geometry Tools/Export/Add Geometry Columns
that are just missing digits to the right for large numbers

Giovanni: which version are you using?

ok to close this part as a duplicate, but the user cannot set the width of the field
in vector/Geometry Tools/Export/Add Geometry Columns, so this specific detail should be
added to #4955

2. The fact that results provided by R are so different. The most intriguing/worrying is
that the R results are using package sp and package Rgeos.
I'm dealing with Edzer Pebesma regarding this issue in R-sig-geo and will keep the list
informed. Perhaps I will open a new ticket on this specific subject but lets wait
to see what Edzer says.

Agus

#6 Updated by Giovanni Manghi about 12 years ago

alobo - wrote:

ok, it seems there are 2 issues here:
1. The wrong results I get with
vector/Geometry Tools/Export/Add Geometry Columns
that are just missing digits to the right for large numbers

Giovanni: which version are you using?

I'm using master, but the issue is definitely #4955

#7 Updated by alobo - about 12 years ago

Update to issue 2: clarified thanks to Roger Bivand, no need to open another
ticket, QGIS, postgis, and R are coincident (but R is much faster than QGIS, few seconds
against few minutes):

"With rgeos 0.2-5 and GEOS runtime version: 3.3.2-CAPI-1.7.2, I have:

bn <- readOGR(".", "BorneoLCv2google")
b2 <- gArea(bn, byid=TRUE)

print(b2[25967], digits=16)
25966
8550196769.93012
print(b2[26570], digits=16)
26569
173647473841.3217

so the hole warnings were the reason for the difference. SVN revision 327 of 16 March enforced the use of createSPComment() in gArea() - the user was expected to denote holes properly themselves before this change. Update your rgeos and try again.

Please update the QGIS #5332 to state that from rgeos 0.2-5, the values are correct. The area slot in the Polygons object is a gross area used to order plotting (because until recently R polygons simply overplotted one another), so it is not guaranteed to be a planar area measure for polygons with holes.

Roger
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail:
"

#8 Updated by Giovanni Manghi about 12 years ago

alobo - wrote:

(but R is much faster than QGIS, few seconds
against few minutes

counts made with the field calculator take also just a few moments (2/3 seconds in my machine), instead of minutes of the tool in the "vector" menu.

#9 Updated by Giovanni Manghi about 12 years ago

  • Resolution set to duplicate
  • Status changed from Feedback to Closed

As for the original description this is duplicate of #4955

Also available in: Atom PDF