Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

Any suggestions are much appreciated,

thanks, mike

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
that was it! thanks for the guidance @nmpeterson –  mikeLdub Mar 14 '13 at 18:11
    
You can sometimes have an easier go of setting up the field mappings if you put it together using the Spatial Join GUI tool, then run it and export it as a python snippet. –  Jay Guarneri Mar 14 '13 at 18:28
1  
@JayGuarneri that's true, if you don't mind your field_mapping parameter being specified as a (typically long and somewhat unweildy/confusing) string, rather than a FieldMappings object. –  nmpeterson Mar 14 '13 at 18:43
    
@nmpeterson Ha! Very true! Still, it can be an easy way to get started. –  Jay Guarneri Mar 14 '13 at 18:45
1  
thanks @JayGuarneri, this was a good exercise for me since I have to adapt the script to multiple datasets, but how can you export the code from the GUI? –  mikeLdub Mar 14 '13 at 18:49
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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