[GIS] Spatial join Python command to summarize attributes

arcgis-10.0pythonspatial-join

I am trying to run the Spatial Join function through the Python shell in ArcGIS 10. When you do the point-and-click method of spatial join, you are given a tool window with an option that asks "How do you want the attributes to be summarized?" However, the Python syntax doesn't show a parameter for this option.

How do I control the attribute summarization through Python? Why is there no parameter for this?

Best Answer

The optional field_mapping parameter is what you're looking for. The page you linked to links to "Mapping input fields to output fields", which will get you started. The mergeRule property of the FieldMap objects is the one that controls which type of statistic/summary to calculate.

Basically you have to create a single FieldMappings object, which is a collection of individual FieldMap objects, each with its own mergeRule.