Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I am just testing this function by itself before I put it in my loop. So I run the test (Python 2.7) and I get a result saying that it was create, but I do not see it in folder I assigned it to. I even tried it on the arcpy box in arcgis 10.2 and I still can't find the layer. I double checked the path I directed it too but nothing.

    import arcpy
    import os        

    arcpy.env.workspace = 'C://Users/my/workspace/'
    arcpy.env.overwriteOutput = True

    inPut = 'C://Users/my/workspace/'

    allStorms = 'allstorms.shp'

    acrpy.MakeFeatureLayer_management (allstorms, inPut+'group1')
share|improve this question

closed as unclear what you're asking by PolyGeo, whuber Mar 12 '14 at 20:40

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

Can you explain exactly what you are trying to accomplish? How would you do it manually (e.g. through ArcMap, without using Python)? – blah238 Mar 12 '14 at 18:15
I am trying to use the SelectLayerByAttribute function to add a selection on a layer. In my allstorms.shp, I am trying to the information in my field name (CONF) and separate it into 3 groups, >80, 60-69, <60. Now that I am explaining this to you, I think I have to make allstorms.shp into a layer because I don not think this attribute take shapefiles – Trey Mar 12 '14 at 18:51
Again, how would you do this manually? Is the desired end result a layer, layer file, feature class, shapefile, other? Please edit your question to include all of the relevant information in your question rather than using the comments. – blah238 Mar 12 '14 at 19:15
I would first go to the ArcToolbox, click on layers and Table Veiws, then select Select layer by Attribute. When the box pops up, under layer name I selected allStorms.shp, under selection I used NEW_SELECTION, and under Epression I used [CONF] >= 80. – Trey Mar 12 '14 at 21:15
I get this error when I do the function in saying Traceback (most recent call last): File "<pyshell#17>", line 1, in <module> arcpy.SelectLayerByAttribute_management("allActiveFire.shp","NEW_SELECTION"," CONF >= 79 ") File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\", line 6688, in SelectLayerByAttribute raise e ExecuteError: Failed to execute. Parameters are not valid. The value cannot be a feature class ERROR 000840: The value is not a Raster Layer. ERROR 000840: The value is not a Mosaic Layer. Failed to execute (SelectLayerByAttribute). – Trey Mar 12 '14 at 22:27

Because 'group1' is in memory, you would need to save it to a layer file if you want to visually confirm its existence. One approach:

import arcpy, os

arcpy.env.workspace = r'C:\Users\my\workspace'
ws = arcpy.env.workspace
arcpy.env.overwriteOutput = True

allStorms = 'allstorms.shp'
acrpy.MakeFeatureLayer_management (allstorms, 'group1')
arcpy.SaveToLayerFile_management ('group1', os.path.join(ws, 'group1' + '.lyr'))
share|improve this answer
would you have to do this when you are using the Select Layer By Attribute function afterwards. My main goal is to make new layer along with a field name and it's data that are greater than 80 from a previous shapefile. I use the ArcGIS resource center for references and their 2 examples uses the makeFeatureLayer_management and then the Select Layer By Attribute_management. I hope I make sense. – Trey Mar 12 '14 at 15:25
No, you do not need to create a layer file when using select layer by attributes. – Aaron Mar 12 '14 at 15:28
Your explain makes more sense since you have to save the layer in order to use it but I am not sure why the example in the ArcGIS resource center does not use the SaveToLayerFile_management. Check it out:… – Trey Mar 12 '14 at 15:29
oh okay. I guess I will try it without creating a layer than. Thank for the help, now I know more about the make a feature layer. – Trey Mar 12 '14 at 15:36
You do not need to save a temporary layer (e.g. 'group1') as a layer file. This is only done if you want to actually visualize the layer. When you use arcpy.MakeFeatureLayer_management(), you are essentially creating a feature stored in your computer's memory rather than being saved to disk. When you quit ArcGIS, the layers are automatically deleted until you create them again. You can use these temporary layers (e.g. 'group1') as input for tools such as SelectLayerByLocation_management (). – Aaron Mar 12 '14 at 15:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.