I used Ar5cPy to do batch processing of Network Analyst - Make Service Area layer of thousand of stores.

Everything went well except now, I am stuck with layer (.lyr) files and I would like to conduct further analysis on the datasets that they contain.

Basically I would have

"SA_Store_001.lyr"  (and so on..)

And when I open this inside ArcMap, it has the usual elements of the Service Area Analysis.


"Route Barriers"

Suppose, I would like to SelectAttributes by polygons, can you give me a skeleton code for this? The help files on ArcGIS on has SelectLayerByAttribute -- what I want is the Polygons.

Unfortunately, this didn't work:

Even the first line doesn't work (because I don't know how to deal with the .lyr file type)

inputLayer = 'D:\\ARCGIS\\FoodSystemsAnalysis\\Coverage\\Auckland\\SMC_SM_Ta9.lyr'

arcpy.MakeFeatureLayer_management(inputLayer, "SMC_Ta9")

arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid. ERROR 000840: The value is not a Feature Layer. Failed to execute (MakeFeatureLayer).

I think the MakeFeatureLayer_management takes features as input.

  • Maybe it doesn't like .lyr files as an input. How are your layer files made? Layer files are just pointers to the REAL data, maybe you could use the original file for the MakeFeatureLayer method (with a where clause if necessary).
    – Roy
    Jul 2, 2012 at 11:29
  • MakeFeatureLayer_management imports shapefiles to layers. If you already have a layer file, use arcpy.mapping.Layer("path_to_layer_file") to create the layer object.
    – bananafish
    Jul 25, 2012 at 3:00

1 Answer 1


If I understand your question correctly:

You can do spatial queries with SelectLayerByLocation. You'll need to use temporary feature layers, but it's easy enough.

Sample code from PSU Master's Program

Once you have your spatial query, you can fiddle down your selection to just the attributes you're interested in with SelectLayerByAttributes using SUBSET_SELECTION as your selection type.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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