3

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

1 Answer 1

2

Tabulate intersection is primarily a geometry analysis tools.

Apart from a bug, the only reason for not having the same number of records when applying it on the same feature class is that you have a few overlapping features in your feature class. Tabulate intersection will then create new features where you have some overlaps, which would explain the "extra" observation and a larger area in total. A topological cleaning could be necessary (in your case removing duplicate points).

For your cross table, I'd rather suggest you to use "Pivot table" (but for obscure reasons it requires advanced license)

1
  • I did find duplicate values that explained this. The data where this subset is picked, shouldn't contain any duplicates, so I didn't even suspect corrupt data. Well, lesson learned here. Pivot Table seems to work very well, I'll update some code snippets for my entry.
    – reima
    Commented Apr 30, 2014 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.