SDE Dataset does not exist or is not supported

1599
4
12-21-2011 11:56 AM
PaulFrank
New Contributor II
Hello,

I would appreciate help from the board.  This is a shortened version of a larger script but this is where the problem seems to lie.  I get the error below even though these layers exist in the mxd.  Ive also run these from arccatalog.  In that case, they usually work, but a couple of times they did not.  That leads me to believe its an SDE issue.  Im running 10, SV2.

ERROR 000732: Input Feature Layer: Dataset FLUM does not exist or is not supported
ERROR 000732: Selecting Features: Dataset ZoningCases does not exist or is not supported
Failed to execute (SelectLayerByLocation).
#--------------------------------------------------------------------------------------------
# Import system modules

import arcpy
from arcpy import env
import os
arcpy.env.overwriteOutput = True

#set workspace
arcpy.env.workspace = r"G:\NEIGHBOR PLAN\ArcView\Projects\Templates\\"

#set mxd
mxd = arcpy.mapping.MapDocument(r"G:\NEIGHBOR PLAN\ArcView\Projects\Templates\test.mxd")

#set dataframe
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]

#select features from FLUM within 2000 feet of ZoningCases
arcpy.SelectLayerByLocation_management("FLUM", "WITHIN_A_DISTANCE", "ZoningCases", "2000 feet", "NEW_SELECTION")

del mxd
#-----------------------------------------------

Thanks!!

Paul Frank
City of Austin
Tags (2)
0 Kudos
4 Replies
PatrickFischer1
New Contributor III
something that may be hindering you is to do with setting your dataframe

#set dataframe
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]

now 'Layers' is only used if that's the exact name of your data frame your data is located in. if you use '*' it becomes a wildcard and selects your active dataframe, that could be you issue alone. Also when you use
import arcpy
from arcpy import env

you do not need to place arcpy.env anytime you want to use an environment setting. also when posting the # icon above your message is for a code block, that's what you see in my post and allows people to scroll through the code rather then the whole page.
0 Kudos
PaulFrank
New Contributor II
Patrick, Thanks for the reply.  I tried to wrap quotes around this post - and it says I cant post because its too short.  Maybe i need a couple of tutorials on this as well.

I do have the suggested ListDataFrames in my original .py file.  I should have attached that originally, but thought I had isolated the problem with my original post.  I would appreciate your looking at this file.

Thanks
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Hi Paul,

I believe you will need to make a feature layer before executing the SelectbyLocation function.  Example:

arcpy.MakeFeatureLayer_management(addflumlayer, "FLUM")
arcpy.MakeFeatureLayer_management(addzcaselayer, "ZoningCases")
arcpy.SelectLayerByLocation_management("FLUM","WITHIN_A_DISTANCE","ZoningCases","2000 Feet","NEW_SELECTION")
arcpy.MakeFeatureLayer_management("FLUM", "FLUM_New")
0 Kudos
PaulFrank
New Contributor II
Hello,

I was able to work through this using some of your suggestions.  I now run the script in ArcMap, which wasnt what i wanted originally, and used a tip about adding MakeFeatureLayer_management output to the display.  But I've run into other issues, namely the mxd is not saving with the output I generate, nor is the legend object adjusting as expected.  But I suppose I need to repost.
0 Kudos