Select to view content in your preferred language

More Code!!!

1188
5
Jump to solution
06-26-2013 08:18 AM
ShikoNjuno
Deactivated User
So now I'm trying to remove buffered roads from the previously selected areas.
    >>> # Remove the buffered roads from the suitable vegetation areas

    >>> erase = arcpy.Erase_analysis(select, "buffer", "in_memory/erase")
    Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\analysis.py", line 205, in Erase raise e ExecuteError: ERROR 000732: Input Features: Dataset in_memory\select does not exist or is not supported

    So then I tried changing the buffer feature, but nothing doing

    >>> erase = arcpy.Erase_analysis(select, buffer, "in_memory/erase")
    Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\analysis.py", line 205, in Erase raise e ExecuteError: ERROR 000732: Input Features: Dataset in_memory\select does not exist or is not supported

    What's strange is that when I selected the vegetation ArcMap created results for that but when I added the buffer code, ArcMap also added it to my list of layers (in addition to showing the results). Could someone help me understand what's going on here.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RhettZufelt
MVP Notable Contributor
Now that you have the model working, you can go to the file menu, export, and export as a python script.

This will give you the basic idea of what would need to be done.  Of course, you won't see the featurelayers being created there, so have to add that in for tools that require them and some syntax may need to be cleaned up.

In any case, it helps me figure this stuff out if I get one working, then export the python and tweak.

R_

View solution in original post

0 Kudos
5 Replies
LindseyWood
Deactivated User
I realize this maybe a new problem for you but it would be helpful to us if you could put your code between the
 
import sys
# arcpy environments and liscences
from arcpy import env
arcpy.CheckOutExtension("spatial")
arcpy.CheckOutExtension("management")
arcpy.env.overwriteOutput = True


etc = Your Code
which you can do by using the # sign at the top.  If it is the same code then it would also be helpful to see more than one line at a time.  Thanks!
0 Kudos
RhettZufelt
MVP Notable Contributor
So now I'm trying to remove buffered roads from the previously selected areas. 
>>> # Remove the buffered roads from the suitable vegetation areas 

>>> erase = arcpy.Erase_analysis(select, "buffer", "in_memory/erase") 
Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\analysis.py", line 205, in Erase raise e ExecuteError: ERROR 000732: Input Features: Dataset in_memory\select does not exist or is not supported 

So then I tried changing the buffer feature, but nothing doing 

>>> erase = arcpy.Erase_analysis(select, buffer, "in_memory/erase") 
Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\analysis.py", line 205, in Erase raise e ExecuteError: ERROR 000732: Input Features: Dataset in_memory\select does not exist or is not supported 

What's strange is that when I selected the vegetation ArcMap created results for that but when I added the buffer code, ArcMap also added it to my list of layers (in addition to showing the results). Could someone help me understand what's going on here.


Think you need to re-read the help for the select and erase tools as suggested here http://forums.arcgis.com/threads/87442-select-arcpy.Select_analysis-HELP!!.

The error is not related to the buffer FC, but what you are trying to use as input from FC that doesn't exist (in_memory\select).


SelectLayerByAttribute doesn't work on FC, must be a layer or view (ArcMap silently substitues a view when you pick FC in Model builder/tools, so if you did that, it will break as stand alone without running MakeFeatureLayer first).

MakeFeatureLayer_management (in_features, out_layer, {where_clause}, {workspace}, {field_info})  ## this will make a feature layer that can be fed into the select tool if this where clause isn't sufficient

SelectLayerByAttribute_management (out_layer, {selection_type}, {where_clause})    ## use the feature layer as input to the select tool.  this puts the selection on the layer until removed or re-selected

FeatureClassToFeatureClass_conversion (out_layer, "C:/output/temp.gdb", "in_features" {where_clause})  # if nothing fancy in your select, you could skip that and makefeature and include your where clause here
                                                                                                      ## in fact, all three support where clause, so if not switching selection, no need for selectlayertool
Erase_analysis ("C:/output/temp.gdb/in_features", buffer, "in_memory/erase"), {cluster_tolerance})  ## use the FC created from the selected values to be erased from.





That should get you on the right track.

Also, as lmwood suggested, it is really hard to try to "guess" what the previous lines of code are (unless I look at all your posts), so having the code that comes before these statements can help. Often something elsewhere in the script that is causing the problems (I.e., wrong variable type, value, etc.).

R_

I am looking in the help documentation for the erase tool, and it does not say if it will honor only the selected feature or not. That is why I convert to featureLAYER with the selection on it to a new in_memory feature class (which would be comprised of only features that were selected) and use this temporary in_memory dataset as your erase feature input.

also, it appears as if you are trying to erase features from your "selection"? Not sure how or even if that would work. Would you expect it to erase the buffers from only the selected features in the input FC?
0 Kudos
ShikoNjuno
Deactivated User
Thanks Lindsey and Rhett
I was able to use a Model instead of a Python Script to accomplish the job.
Clearly I have a long way to go with Scripting in Python, but I really appreciate your help.
Cheers

Shiko
0 Kudos
RhettZufelt
MVP Notable Contributor
Now that you have the model working, you can go to the file menu, export, and export as a python script.

This will give you the basic idea of what would need to be done.  Of course, you won't see the featurelayers being created there, so have to add that in for tools that require them and some syntax may need to be cleaned up.

In any case, it helps me figure this stuff out if I get one working, then export the python and tweak.

R_
0 Kudos
ShikoNjuno
Deactivated User
That's really good to know.
Sooo helpful!!!....I'll definitely be playing around with that.
😄
0 Kudos