Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i require to spatial join the shapefile having attribute by ie selecting by attribute which remains same for the target and join feature and get the output as per attribute selected i want to prepare a model to optimise the workflow I am new with model builder and using 9.3 arc GIS any script or model will be to great help.

spatial join by attribute match between line and ploygon with attribute of points. i.e iterator is not available in lower version so could not try that.

share|improve this question

You can simply incorporate the Spatial Join tool, which is available in ArcGIS 9.3, into your model.

Alternatively, you can use python scripting in 9.3:

    # Create the geoprocessor object
import arcgisscripting, sys

gp = arcgisscripting.create()

# Want to join USA cities to states and calculate the mean city population
# for each state
targetFeatures = "C:/data/USA.gdb/states"
joinFeatures = "C:/data/USA.gdb/cities"

# Output will be the target features, states, with a mean city population field (mcp)
outfc = "C:/data/USA.gdb/states_mcp"

# Create a new fieldmappings and add the two input feature classes.
fieldmappings = gp.CreateObject("FieldMappings")

# First get the POP1990 fieldmap. POP1990 is a field in the cities feature class.
# The output will have the states with the attributes of the cities. Setting the
# field's merge rule to mean will aggregate the values for all of the cities for
# each state into an average value. The field is also renamed to be more appropriate
# for the output.
fieldmap = fieldmappings.GetFieldMap(fieldmappings.FindFieldMapIndex("POP1990"))

# Get the output field's properties as a field object
field = fieldmap.OutputField

# Rename the field and pass the updated field object back into the field map
field.Name = "mean_city_pop"
field.AliasName = "mean_city_pop"
fieldmap.OutputField = field

# Set the merge rule to mean and then replace the old fieldmap in the mappings object
# with the updated one
fieldmap.MergeRule = "mean"
fieldmappings.ReplaceFieldMap(fieldmappings.FindFieldMapIndex("POP1990"), fieldmap)

# Delete fields that are no longer applicable, such as city CITY_NAME and CITY_FIPS
# as only the first value will be used by default
x = fieldmappings.findfieldmapindex("CITY_NAME")
x = fieldmappings.findfieldmapindex("CITY_FIPS")

#Run the Spatial Join tool, using the defaults for the join operation and join type
gp.SpatialJoin(targetFeatures, joinFeatures, outfc, "#", "#", fieldmappings)
share|improve this answer
thanks for the suggestion, i am working like that but the no of attributes are large and i have time constraint so wanted some automation sort of model or tool as i dont know scripts tecnique – janak Nov 27 '12 at 18:56

Your Answer


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.