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

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.

share|improve this question
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 '12 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 '12 at 3:00

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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