AnsweredAssumed Answered

ArcPy Bug?- Find closest facility ERROR 001156: could not write value '32768' to output field ORIG_FID

Question asked by akmanchianand on Jul 27, 2017
Latest reply on Jul 31, 2017 by akmanchianand

I am unable to solve a closest facility problem in ArcGIS Desktop 10.2.2 with ArcPy using the sample code provided in help documentation.

 

I get this error:

ERROR: A geoprocessing error occurred.
ERROR 001156: Failed on input OID 32768, could not write value '32768' to output field ORIG_FID
Failed to execute (FeatureClassToFeatureClass).
An error occured on line 27
A geoprocessing error occurred.
ERROR 001156: Failed on input OID 32768, could not write value '32768' to output field ORIG_FID
Failed to execute (FeatureClassToFeatureClass).
Failed to execute (FindClosestFacilities).

It seems to me this is a bug with field mapping that is occurring internally. Its obvious that ORIG_FID should be a long int and it actually is short int. That is why we are seeing this exception at 32768.

 

I am using the San Francisco network dataset available in ArcGIS tutorial data, with some randomly generated facilities (about 100,000) over the area.

 

This is the code that throws the error.

import arcpy
from arcpy import env

try:
    # Check out the Network Analyst extension license
    arcpy.CheckOutExtension("Network")

    # Set environment settings
    env.workspace = r'C:\arcgis\ArcTutor\Network Analyst\Tutorial\SanFrancisco.gdb'
    env.overwriteOutput = True

    # Set local variables
    inNetworkDataset = r'C:\arcgis\ArcTutor\Network Analyst\Tutorial\SanFrancisco.gdb\Transportation\Streets_ND'
    inIncidents = r'D:\Sample data\sampledata.gdb\incident'
    inFacilities = r'D:\Sample data\sampledata.gdb\manholes_sf'
    outGeodatabase = r'D:\Sample data\sampledata.gdb'
    #outGeodatabase = "in_memory"
    outRoutes = "Routes"
    outDirections = "Directions"
    outClosestFacilities = "ClosestFacilities"
    measurement_units = "Meters"

    # Run FindClosestFacilities. Choose to find only the closest facility.
    arcpy.na.FindClosestFacilities(inIncidents, inFacilities, measurement_units,
                                    inNetworkDataset, outGeodatabase, outRoutes,
                                    outDirections, outClosestFacilities,
                                    Number_of_Facilities_to_Find=1)

    print "Script completed successfully"

except Exception as e:
    # If an error occurred, print line number and error message
    import traceback, sys
    tb = sys.exc_info()[2]
    print "An error occured on line %i" % tb.tb_lineno
    print str(e)

Outcomes