This is the code I am using:# -*- coding: cp1252 -*-
# Import modules
import arcpy, arcgisscripting, json
try:
#Workspace
#arcpy.env.workspace = r"C:\temp\\"
gp = arcgisscripting.create()
# ENV Settings
arcpy.env.overwriteOutput = 1
# Local variables
i = 0
value = 0
ptList = []
rowNumberList = []
pt = arcpy.Point()
#String input:
input = arcpy.GetParameterAsText(0)
#JSON array to Python dictionary
data = json.loads(input)
for entries in data['points']:
rowNumberList.append(data['points']['rowNumber'])
pt.X = data['points']['longitude']
pt.Y = data['points']['latitude']
ptList.append(arcpy.PointGeometry(pt))
i += 1
# Create the Shape
arcpy.CopyFeatures_management(ptList, r"pointTemp.shp")
# Add the filed 'rowNumber'
arcpy.AddField_management(r"pointTemp.shp", "rowNumber", "SHORT")
# Fill the field 'rowNumber'
cur = gp.UpdateCursor(r"pointTemp.shp")
row = cur.Next()
while row:
row.rowNumber = rowNumberList[value]
cur.UpdateRow(row)
row = cur.Next()
value += 1
del cur
# Spatial Join
arcpy.SpatialJoin_analysis(r"pointTemp.shp",r"C:\arcgisserver\directories\arcgissystem\arcgisinput\cresta\lowres_deutschland.MapServer\extracted\v101\cresta.gdb\Cresta_Low_Res",r"join_result.shp")
# FeatureClass / Shapefile,
fc = r"join_result.shp"
# Fields that should be returned by the cursor
field = ["CRESTA_ID"]
# Loop through the attribute table with a cursor
with arcpy.da.SearchCursor(fc, field) as cursor:
for row in cursor:
print str(row[0])
arcpy.SetParameterAsText(1, "Eintrag: " + str(row[0]))
except Exception, e:
arcpy.SetParameterAsText(2, e)
My problem is in the spatial join function. Here I need to tell the script where he has to search for the second shape/feature class to join with the point shape.