0

I am trying to generate random lines within a polygon using ArcMap 10.6.1, in the Python window. I have entered the code that was supplied in this post and changed the relevant file paths.

Here is the error message:

Runtime error Traceback (most recent call last): File "", line 15, in File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\management.py", line 3435, in AddField raise e ExecuteError: ERROR 000732: Input Table: Dataset in_memory/rand_points does not exist or is not supported

I'm new to python and can't figure out the error.

Here is the code in it's entirety with error message at the end:

>>> import arcpy, os, random
... 
... 
... arcpy.env.overwriteOutput = 1
... 
... 
... outws = r"C:\Users\Leo\GIS\e53f4ad724884ee8a0c033396db0c4f4.gdb"
... # Where the output feature class and table will go. This assumes a file geodatabase
... 
... 
... polygon = r"C:\Users\Leo\GIS\e53f4ad724884ee8a0c033396db0c4f4.gdb\Humuula" # The study area polygon (Note this is in a feature dataset)
... transect_distance = 50 # The transect distance
... n_lines = 20 # How many transects
... 
... # Create random points offset from study area boundary by X distance
... arcpy.Buffer_analysis(polygon, "in_memory/buffer", -transect_distance) # negative buffer study area to get correct offset
... arcpy.CreateRandomPoints_management("in_memory", "rand_points", "in_memory/buffer", "", n_lines)
... 
... # Add fields x, y, distance, and bearing
... arcpy.AddField_management("in_memory/rand_points", "x", "DOUBLE")
... arcpy.AddField_management("in_memory/rand_points", "y", "DOUBLE")
... arcpy.AddField_management("in_memory/rand_points", "distance", "FLOAT")
... arcpy.AddField_management("in_memory/rand_points", "bearing", "FLOAT")
... 
... # Run cursor to update attribute table with pertinent data for bearing distance tool
... with arcpy.da.UpdateCursor("in_memory/rand_points", ["SHAPE@XY", "x", "y", "distance", "bearing"]) as cursor:
... for row in cursor:
... row[1] = row[0][0]
... row[2] = row[0][1]
... row[3] = transect_distance
... row[4] = random.randint(1,360)
... cursor.updateRow(row)
... 
... # Create a table to feed to Bearing Distance to line tool
... arcpy.TableToTable_conversion("in_memory/rand_points",outws,"out_table")
... 
... # Generate the transects
... arcpy.BearingDistanceToLine_management (os.path.join(outws, "out_table"), os.path.join(outws, "transects"), x_field = 'x', y_field = 'y', distance_field = 'distance', bearing_field = 'bearing', spatial_reference = "in_memory/rand_points")
... 
... # Clean up
... arcpy.Delete_management(os.path.join(outws, "out_table"))
... 
... print "Processing complete."
... 
Runtime error Traceback (most recent call last): File "<string>", line 20, in <module> File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\management.py", line 3435, in AddField raise e ExecuteError: ERROR 000732: Input Table: Dataset in_memory/rand_points does not exist or is not supported 
>>> 
Maxima
1,6999 silver badges18 bronze badges
asked Sep 13, 2018 at 22:26
3
  • Is your background processing enabled? If so, try to disable it. Commented Sep 14, 2018 at 0:21
  • @SonofaBeach I included the code. Commented Sep 14, 2018 at 0:42
  • @fatih_dur that was it! Problem solved, thank you. Commented Sep 14, 2018 at 0:46

1 Answer 1

2

This ESRI product support article explains why this error occurs. According to my experience, if you are sure that the data exists (in your case if arcpy.Exists("in_memory/rand_points") returns True), the usual culprit related to the in_memory workspace is background processing. It is explained in this help page as well. I would start from here to see if it resolves the issue and, if not, follow the other actions advised in the support page.

answered Sep 14, 2018 at 1:10

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.