0

Being new to ArcMap, and ArcPy I have a problem with a script including several geoprocessing functions. The number of functions inspired a search for a means to save outputs (subsequent inputs) to memory, leading to the 'in_memory' assist provided by ArcMap.

However the following script errors out at the RasterToPolygon_Conversion() and I am unsure why...

import arcpy

arcpy.CheckOutExtension("spatial")
arcpy.env.overwriteOutput = True
arcpy.env.workspace = "C:\\Users\\Important\\testMap.mxd"

DEM_raster_layer = "C:\\canyon.tif"
Camera_point_layer = "C:\\birdsEye.shp"

# Process: Visibility analysis
arcpy.gp.Visibility_sa(DEM_raster_layer, Camera_point_layer, "in_memory\\0", "",\
                      "FREQUENCY", "NODATA", "0.00001201","FLAT_EARTH", "0.13", "", "",\
                      "OFFSETA", "", "", "AZIMUTH1", "AZIMUTH2", "VERT1", "VERT2")

# Process: Visibilty boundries cleanup
arcpy.gp.BoundaryClean_sa("in_memory\\0", "in_memory\\1", "ASCEND", "TWO_WAY")
arcpy.Delete_management("in_memory\\0")

# Process: Visibility raster to polygon(s)
arcpy.RasterToPolygon_conversion("in_memory\\1", "in_memory\\2", "NO_SIMPLIFY", "")
arcpy.Delete_management("in_memory\\1")

Here is the following error return:

Runtime error Traceback (most recent call last): File "", line 32, in File "c:\arcgis\desktop10.2\arcpy\arcpy\conversion.py", line 244, in RasterToPolygon raise e ExecuteError: ERROR 000582: Error occurred during execution.

Im guessing there is some syntax or logic mistake in this method?

  • 1
    Have you tried running RasterToPolygon_Conversion() with output to an in_memory dataset in the ArcMap GUI? Some geoprocessing tools (e.g. project) don't allow outputting to in_memory datasets. – dmahr Jun 9 '15 at 12:33
  • @dmahr : Successful manual output of 'in_memory' in the ArcMap GUI. I'm wondering if its the previous 'in_memory' input... – Katalpa Jun 9 '15 at 12:35
3

Well, after helpful advice from 'dmahr' I manually tested this process in the ArcMap GUI and it worked successfully. That drew on the conclusion that possibly a naming issue was at fault.

Indeed such seemed to be the case. After using a text+numeric name, the processing worked without troubles.

The following ad hoc changes temporarily resolved the problem:

import arcpy

arcpy.CheckOutExtension("spatial")
arcpy.env.overwriteOutput = True
arcpy.env.addOutputsToMap = False
arcpy.env.workspace = "C:\\Users\\Important\\testMap.mxd"

DEM_raster_layer = "C:\\canyon.tif"
Camera_point_layer = "C:\\birdsEye.shp"

# Process: Visibility analysis
arcpy.gp.Visibility_sa(DEM_raster_layer, Camera_point_layer, "in_memory\\something1", "", "FREQUENCY", "NODATA", "0.00001201", \
                             "FLAT_EARTH", "0.13", "", "", "OFFSETA", "", "", "AZIMUTH1", "AZIMUTH2", "VERT1", "VERT2")

# Process: Visibilty boundries cleanup
arcpy.gp.BoundaryClean_sa("in_memory\\something1", "in_memory\\something2", "ASCEND", "TWO_WAY")
arcpy.Delete_management("in_memory\\something1")

# Process: Visibility raster to polygon(s)
arcpy.RasterToPolygon_conversion("in_memory\\something2", "in_memory\\something3", "NO_SIMPLIFY", "")
arcpy.Delete_management("in_memory\\something2")
  • 3
    Good detective work. This is probably because in_memory datasets are treated like geodatabase feature classes, which (I now remember) cannot start with numbers. – dmahr Jun 9 '15 at 14:32
  • Great future reference. – Katalpa Jun 9 '15 at 15:01
  • 1
    Have a look at the ValidateTableName function, it can be used to watch for these sorts of cases. For example, arcpy.ValidateTableName('1', 'in_memory') returns 'T1'. – DWynne Jun 9 '15 at 17:16

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.