Using ArcMap 10.2 I am getting the ERROR: 000714 for this script. Therefore I am having trouble debugging it.
The purpose of my script is to spatially join points to lines in ArcGIS. And is simply a test script that will become part of a larger scripted tool. The script I am currently working off is as per below which is largely a copy/paste from ArcGIS Spatial Join Help, which I have modified for my .shp files and a count field.
# Spatial Join Script
# Initiating top of catchment junction connections to pipes.
# Process: Spatially join points to lines with count field.
# Import system modules
import os
import arcpy
# Set workspace environment
arcpy.env.workspace = "c:/.../Python/SpatialJoinTest"
arcpy.env.overwriteOutput = True
# Script arguments
PointInput = arcpy.GetParameterAsText (0)
LineInput = arcpy.GetParameterAsText (1)
#Set Variables
Outputs = "C:/.../Python/SpatialJoinTest/Outputs"
LW = Outputs + "/" + "LineWorking.shp"
PW = Outputs + "/" + "JunctionWorking.shp"
O_PL = Outputs + "/" + "PointLine_JoinCount.shp"
# Creating Working Shapefiles
arcpy.CopyFeatures_management (LineInput, LW)
arcpy.CopyFeatures_management (PointInput, PW)
# Want to join Points to Lines and 'count' the number of joins for each pipe to junction
''' I note that in this section in the help file .gdb were referenced rather than .shp
Thus: I think it is these lines where I am going wrong(?)'''
targetFeatures = os.path.join(PW)
joinFeatures = os.path.join(LW)
# Output will be the target features, (Points) with the 'count' of Lines joined.
outfc = os.path.join(O_PL)
# Create a new fieldmappings and add the two input feature classes.
fieldmappings = arcpy.FieldMappings()
fieldmappings.addTable(targetFeatures)
fieldmappings.addTable(joinFeatures)
# First get the 'L_ID' fieldmap. 'L_ID' is a field in the 'LW' feature class.
# The output will have the 'ID' with the 'count' of connecting lines. Setting the
# field's merge rule to 'count' will count the connections for all of the points for
# each line intersecting. The field is also renamed to be more appropriate
# for the output.
L_IDFieldIndex = fieldmappings.findFieldMapIndex("L_ID")
fieldmap = fieldmappings.getFieldMap(L_IDFieldIndex)
# 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 = "L_COUNT"
field.aliasName = "L_COUNT"
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 = "Count"
fieldmappings.replaceFieldMap(L_IDFieldIndex, fieldmap)
#Run the Spatial Join tool, using the defaults for the join operation and join type
arcpy.SpatialJoin_analysis(targetFeatures, joinFeatures, outfc, "JOIN_ONE_TO_MANY", "KEEP_COMMON", fieldmappings, "INTERSECT")
How can I make the above work?
My guess is it is to do with os.path.join() commands, however my experience is limited.
The error message is below:
Running script SpatialJoinScript... ERROR 000714: Error in script SpatialJoinScript. Error in executing: cmd.exe /C D:...\Python\SpatialJoinScript.py "D:\Michael Austin - Working\GIS\Python\20180323\Inputs\Point.shp" "D:...\Python\20180323\Inputs\Line.shp"
Failed to execute (SpatialJoinScript). Failed at Mon Apr 09 11:57:52 2018 (Elapsed Time: 0.06 seconds)
arcpy.GetParameterAsText (0)
.