AnsweredAssumed Answered

Spatial join between one target feature and several join features ?

Question asked by heidisevestre on May 31, 2012
Latest reply on May 31, 2012 by heidisevestre
Dear all with Python experience,

In advance, please excuse the little experience I have dealing with Python, as I am trying to write my very first script!

My situation is that I would like to perform spatial join between one single "target feature" and several "join features". The aim is to create as many output files as I have join features.
In addition (but I have absolutely no idea how) I would like each output file to keep the file name from the join feature file.

So far, my script looks like this:

import arcpy
import os

# Create the geoprocessor object
     # 9.2 and beyond   
     import arcgisscripting
     gp = arcgisscripting.create()
     print "\nImporting geoprocessor for 9.2 and beyond..."   
     # 9.1 and before   
     import win32com.client
     gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")
     print "\nImporting geoprocessor for 9.1 and before..."

targetFeatures = "G:/PhD/ERA 40/WorkPython/target/"
joinFeatures = "G:/PhD/ERA 40/WorkPython/join/"
outfc = "G:/PhD/ERA 40/WorkPython/Output"

# Read all the shapefiles in folder 'joinFeatures'
gp.SpatialJoin(targetFeatures, joinFeatures, outfc, "JOIN_ONE_TO_ONE", "KEEP_ALL")

print "\nDone."

Without surprises this script doesn't perform well, and I am not able to get anything out of it.

My target feature file is "Alaska_20111229_geog_glaciers.shp"
My join feature files are called "09011981small.shp", the first 8 digits changing for every single file.

Any help/improvement/advice would be very much appreciated. Thank you!
Kind regards,