Difference between !shape.area! and Calculate Geometry > area

21345
35
05-18-2016 05:46 AM

I have a shapefile with 62.000 polygons.

I have created two fields (Double) AREA1 and AREA2 with identical properties.

On AREA1 I have calculated the area of polygons with Calculate Geometry > area process.

On AREA2 I have calculated the area of polygons with Field calculator and the command: !shape.area!

When I compare the difference between the two fields ([AREA1] - [AREA2]), I find 30 polygons with no zero difference less than 0,01 square meters.

Is there a different algorithm for these processes?

Does anyone know why is this happening?

35 Replies
DanPatterson_Retired
MVP Emeritus

great

0 Kudos

Well I had a small change on the parameters of the question.

First the problematic polygons are 31.

The differences are on the 7th decimal (aka 0,0000001).

I know that this difference is quite small but the quality tests of the project that I work on does not want this kind of differences.

I also noticed that the calculation for AREA2 lasts from 3 to 4 times more than AREA1.

I attached the 31 polygons that have the difference, as requested.

https://onedrive.live.com/redir?resid=AF5E4C8DEC50543E!457058&authkey=!AEIBlooHmQ1Fu-o&ithint=file%2...

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

I am running ArcMap 10.4 on Windows 7 x64 Enterprise Edition.

When I preview your shapefile in ArcCatalog, I don't see any differences at all:

area_diffs.png

0 Kudos
DanPatterson_Retired
MVP Emeritus

No errors... your problem is a display issue, your geometry is correct.

Area_comparison.png

0 Kudos

Thanks for your replies but....

As you can see on the following screanshot there errors and they are visible and countable.

diffs1.jpg

Also if you try to Select by attributes with AREA1 <> AREA2, all polygons are selected.

And with ArcCatalog, on the view of the table, it uses the default size for decimals (6 digits), that's why you see only zeros.

As you can see there are a few polygons that have 0,000000000 as difference. I assume that the difference is even smaller (probably 0,0000000001). If you change the number format of the DIFF field in scientific, you will see the exact difference, as follows:

diffs2.jpg

The main question for this is WHY is it happening?

When we use Python programming, we want to automate the EXACT actions we do by hand.

If the Calculate Geometry tool, uses a different algorithm to calculate the area of a polygon related to the Pythonic syntax !shape.area!, then the least ESRI should do is to document it and explain WHY it happens.

The second step for all this would be to solve this problem.

0 Kudos
curtvprice
MVP Esteemed Contributor
The main question for this is WHY is it happening?

Binary numbers are not represented exactly, and these calculations are all done in binary, not decimal, arithmetic.

Floating point - Wikipedia, the free encyclopedia

Shapefiles store numbers as ascii digits so you tend to see a lot of rounding on save. I'm thinking your data are getting rounded off when you export the selected records in the shapefile that you shared.

0 Kudos
NeilAyres
MVP Alum

Perhaps there is a slight difference ( very small) and in area terms is extremely tiny % of 1m2.

So, to be realistic, why not use whichever is quicker to calculate and round the result to 2 decimals.

0 Kudos

You are correct.

In real world, on the field of environmental and landuse surfaces, differences in area less than 1 square millimeter are negligible.

On the other hand, the fact that there is a difference is a problem.

When you calculate areas on the same polygons, on the same format (shapefile) and with the same program, the results must be the same.

At the same time, which of the two areas is the correct one, as long as they can't be both?

And when I have more than 100 shapefiles to calculate the area, I expected to be able to simulate the Calculate Geometry tool with the Calculate Field tool and the command !shape.area!.

Apparently, what I was expecting was not the case, and I will have to make the calculation manually but I think it should be documented by ESRI that the two algorithms are different and produce slightly different results.

0 Kudos
NeilAyres
MVP Alum

I think you are being unnecessarily pedantic. And in the real world, no one is mapping anything especially environmental or landuse variables to a resolution of 1 square millimeter. And your difference is a billion times smaller than that.

I don't think I am pedantic.

If the produced shapefiles cannot pass the quality testing of our clients, we won't get paid.

In order to avoid this, I will have to explain why this is happening.

The options are two:

  1. Wait ESRI to fix it.
  2. Wait ESRI documented in detail, so that I can support the result.

P.S.: Some differences are 0.0000001m2 that equals to 0,1mm2

0 Kudos