I'd like to produce a simple crosstabulation from two fields of a point feature class. These fields contain land use class information which I'd like to compare.
One option is to export a dbf and do this with Excel or with R. Another option that might work is to use ArcMap TabulateIntersection -tool. (Although it returns a flat table with matching classes and observations rather than a real crosstable.)
This is how it looks in arcpy:
TabulateIntersection_analysis (in_zone_features, zone_fields, in_class_features, out_table, {class_fields}, {sum_fields}, {xy_tolerance}, {out_units})
# My version: Cross-table class1 values and class2
arcpy.TabulateIntersection_analysis(Plots,"class1",Plots,path+OutTable,"class2","#","#","UNKNOWN")
For what I understand of this, this should compare the values of two fields of the same file - as the file is given here twice. And it sort of does, except the result is different from the first method I told (I tabulated this in R). Also there are same 'extra' observations. There are 4560 plots in my data and the latter method returns c. 4700 observations. The results are close to each other, but there are a some discrepancies. Does anyone have an idea what I might do wrong here?
Pivot table code snippets for crosstabulation:
#1.calculate frequencies:
arcpy.Frequency_analysis(Plots,path+OutFreq,"class1;class2","#")
#2.make a pivot table
arcpy.PivotTable_management(OutFreq,"class1","class2","FREQUENCY",path+OutPivot)
This video might also be helpful: https://www.youtube.com/watch?v=9dGjuEQie7Y