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()

# 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)

  • Can you write the error message in your post? – Marcelo Villa Apr 9 '18 at 1:54
  • It could be the hyphen in your source path, try changing "D:\Michael Austin - Working" to "D:\Michael Austin Working" – Dan Apr 9 '18 at 2:46
  • That's a particularly non-helpful error message, can you put in a couple of arcpy.AddMessage(sys._getframe().f_lineno) statements (see stackoverflow.com/questions/3056048/…) to find out what line the error is on - you will need to import sys first. – Michael Stimson Apr 9 '18 at 2:48
  • 1
    You'll need a lot of them, every blank line for a start, then when the error causing line is located you can find and replace arcpy.AddMessage(sys._getframe().f_lineno) with an empty string to get rid of them all at once or put a # in front just in case you need them again. – Michael Stimson Apr 9 '18 at 3:22
  • 1
    Always best to debug without arcpy.GetParameterAsText (0). – Aaron Apr 9 '18 at 4:10

There were three errors in my script.

The first was the inclusion of os.path.join() - this is not required as I am not using a .gdb.

The corrected code for this section is below:

# Want to join Points to Lines and 'count' the number of joins for each pipe to junction
targetFeatures = PW
joinFeatures = LW

# Output will be the target features, (Points) with the 'count' of Lines joined.
outfc = O_PL

The second error was: L_IDFieldIndex = fieldmappings.findFieldMapIndex("L_ID") This field exists in my larger script but not in my 'test' script'

The third error is on the last line: "JOIN_ONE_TO_ONE" - in order to keep a count I need to join one to one so the points aren't duplicated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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