AnsweredAssumed Answered

Outputting results message from spatial statistics tool to text file using python

Question asked by jpdexacuk on May 22, 2012
Latest reply on May 24, 2012 by jpdexacuk

I'm using the following tool in ArcGIS 10 - Calculate Distance Band from Neighbor Count (Spatial Statistics). I'm using a python script to execute this tool several times on different shapefiles:

    import arcpy
    arcpy.env.workspace = "c:/data"
    mindist, avgdist, maxdist = arcpy.CalculateDistanceBand_stats("Blocks1", 1, "EUCLIDEAN_DISTANCE")
    mindist, avgdist, maxdist = arcpy.CalculateDistanceBand_stats("Blocks2", 1, "EUCLIDEAN_DISTANCE")
    mindist, avgdist, maxdist = arcpy.CalculateDistanceBand_stats("Blocks3", 1, "EUCLIDEAN_DISTANCE")

At the moment, this outputs the 3 result values to the Results-Messages window in ArcMap 10, overwriting the past results each time. Is there any way I can write these values to a text file after each execution of the tool using python code. If possible I would like to run this on many shapefiles and write the output values to the same text file. If a text file isn't feasible, then anything that can store this information will suffice.

I'm also getting this error at the moment - Runtime error <type 'exceptions.RuntimeError'>: ResultObject: Error in getting output

If I could just output this ResultObject to a file somewhere for each of the toolbox outputs, that would be great!

Any help much appreciated!