Issue with SQL Expression using "in_memory" dataset

451
1
02-25-2012 07:34 AM
ChrisKarstens
New Contributor
I am trying to perform an SQL expression within the MakeFeatureLayer_management tool on a dataset stored in the "in_memory" workspace, like this...

arcpy.MakeFeatureLayer_management("in_memory\\resourceOL", "in_memory\\resourceOL_layer", "\"landuse\" = 0")

But this isn't working.  I've also tried '"landuse" = 0', which didn't work either.  However, when I run the "Make Feature Layer" tool from the System Toolboxes, it works fine.  My current work around is to use arcpy.UpdateCursor() to delete rows where values in landuse != 0.

So, my questions are:

a) Am I doing something obviously wrong (e.g., syntax)?

b) If not, has anyone else experienced this?

c) If so, is this a bug within the arcpy module? 

I am new to the forum, so I apologize if this has already been discussed (I wasn't able to find anything in a quick search).

Thank you,

Chris Karstens
Tags (2)
0 Kudos
1 Reply
AlessandroCinnirella
New Contributor III
the second argument of arcpy.MakeFeatureLayer_management is the name of the layer, not the "location".

change your code in arcpy.MakeFeatureLayer_management("in_memory\\resourceOL", "resourceOL_layer", "\"landuse\" = 0")

should work.

ciao,
AC
0 Kudos