Select to view content in your preferred language

Code Help!!!

514
3
Jump to solution
06-26-2013 07:50 AM
ShikoNjuno
Occasional Contributor
Below is a script I'm attempting to write for the selection of appropriate trees to meet certain criteria. I keep getting the following error and I'm not quite sure what to change.
Could somebody suggest what I could try to fix it.
Thanks.


>>> # Select vegetation areas with the correct type

>>> select = arcpy.Select_analysis("Vegetation", "in_memory/select", """ "VEG_TYPE" In ('Coastal Sage-Chaparral Scrub','Diegan Coastal Sage Scrub','Maritime Succulent Scrub')"""
...
Parsing error SyntaxError: invalid syntax (line 2)
>>>
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JasonScheirer
Regular Contributor II
Need to close the paren:

select = arcpy.Select_analysis("Vegetation", "in_memory/select", """ "VEG_TYPE" In ('Coastal Sage-Chaparral Scrub','Diegan Coastal Sage Scrub','Maritime Succulent Scrub')""")

View solution in original post

0 Kudos
3 Replies
JasonScheirer
Regular Contributor II
Need to close the paren:

select = arcpy.Select_analysis("Vegetation", "in_memory/select", """ "VEG_TYPE" In ('Coastal Sage-Chaparral Scrub','Diegan Coastal Sage Scrub','Maritime Succulent Scrub')""")
0 Kudos
ShikoNjuno
Occasional Contributor
That worked 😄
Thanks so much.

BTW I'm working on quite a large script and I'm not well versed with Python so you'll probably hear from me again throughout the day.
:confused:
0 Kudos
ShikoNjuno
Occasional 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.
0 Kudos