I know this is an old thread, but it was not actually answered as far as I can see. I would certainly prefer R over any desktop GIS package for any operations involving attribute tables.The last approach recommended (but not demonstrated) by @MyGIS is one I use frequently - here's how to do it in R:
To begin, I have two shape files containing polygons, and I want to know if they are different (they should not be, but I fear they may be). I import both shape files into R, using the sf package:
library(sf)
old_SE <- st_read("siose05_REC_COMP.shp")
new_SE <- st_read("siose05_REC_COMP_MADRID_SE.shp")
head(old_SE) #check the file and show the first 6 records in the attribute table
head(new_SE) #check the file and show the first 6 records in the attribute table
#first, check that they are not actually identical
identical(new_SE,old_SE)
[1] FALSE
#ok, fine, we go on...
old_SE$area <- st_area(st_geometry(old_SE)) #calculate the area of the polgons and add a new attribute table called "area"
new_SE$area <- st_area(st_geometry(new_SE)) #calculate the area of the polgons and add a new attribute table called "area"
areascf <- as.data.frame(cbind(old_SE$area,new_SE$area)) #bind the two columns together into a new dataframe. This will only work if both the original files have the same number of rows. if we are not certain that this is the case, we can check with length(st_geometry(new_SE)) for each file.
#and inspect the new data frame we created:
> head(areascf)
V1 V2
1 3329963.76 3329963.76
2 9019401.17 9019401.17
3 11946003.36 11946003.36
4 88149.58 88149.58
5 362726410.62 362726410.61
6 182194640.92 182194640.92
#rename the columns something more useful
colnames(areascf) <- c("old","new")
#create a new column showing the difference in area between the two shape files
#I rounded up to 3 dps to avoid very small differences.
areascf$diff <- round(areascf$old-areascf$new,3)
areascf
old new diff
1 3329963.76 3329963.76 0.000
2 9019401.17 9019401.17 0.000
3 11946003.36 11946003.36 0.000
4 88149.58 88149.58 0.000
5 362726410.62 362726410.61 0.006
6 182194640.92 182194640.92 0.000
7 996525.61 996525.61 0.000
8 570390.89 570390.89 0.000
9 1988238.58 1988238.58 0.002
10 7800656.42 7800656.42 0.000
11 20168058.82 20168058.82 0.000
12 1081882.23 1081882.23 0.000
13 12461270.34 12461270.33 0.001
14 17473784.76 17473784.77 -0.010
15 73942146.44 73942146.44 0.000
16 623481292.98 623481293.00 -0.015
17 154669526.15 154669526.15 0.002
18 1878343.04 1878343.04 0.000
19 7532929.98 7532929.98 0.000
20 41260279.37 41260279.37 -0.002
21 854978.09 854978.09 0.000
22 1299636.02 1299636.02 0.000
23 264717.59 264717.59 0.000
24 3478200.96 3478200.96 0.000
25 39736401.64 39736401.64 0.000
26 1951992.11 1951992.11 0.000
27 27268888.54 27268888.54 0.000
28 1512236.56 1512236.56 0.000
29 273531.01 273531.01 0.000
>
Though many polygon areas disagree slightly, the differences are not large, the largest difference is feature 16, in this case the polygon in the new file is around 15cm2 larger than the old one.