Select by Location - "Use Selected Features" Check Box

1466
6
04-07-2012 08:42 PM
BrittanyGale
Occasional Contributor
Hello everyone,

Is there any way to check the "Use Selected Features" check box in the Select by Location dialog box using ArcPy?

Also, is there any way to buffer only the selected features of a feature class?

Thank you!
Tags (2)
0 Kudos
6 Replies
Zeke
by
Regular Contributor III
I'm not sure if you can check the box, but I believe most tools, including buffer, only run on selected features, if there are any selected. I think the actual dialog box has the checkbox selected by default; either that, or it's an option or uses the last checked/unchecked status. Mine's always checked, so not sure.
0 Kudos
BrittanyGale
Occasional Contributor
That's what I thought: buffers only run on the selected features. So, I tried doing that: selecting the desired feature and running a buffer through arcpy, but it buffered all of the features. Hmm... I will try again when I get around to it again. Thank you!
0 Kudos
Zeke
by
Regular Contributor III
Well, that's odd. When I run the buffer tool in arcpy, it only runs on selected features. Are you using ArcGIS 10? Shapefiles or feature classes? How many features does the selection tab in the TOC show selected? If you're selecting the features in arcpy, try selecting them manually before running the buffer to see if that makes a difference. Or vice versa.
0 Kudos
DanPatterson_Retired
MVP Emeritus
For selections to be honored, the layer must be selected as a parameter, not the file on disk.  If you create a tool for use in arctoolbox, then selections will be kept, if you select the file from disk then all features will be used regardless of a selection.
0 Kudos
Zeke
by
Regular Contributor III
What do you mean by 'select a file on disk'? Select it in Windows Explorer? Don't you just select features either manually with the Select tool, or with a query from the Selection menu, from the attribute table dropdown, or via arcpy? Guess I've just never run across that term.
0 Kudos
FabianBlau
Occasional Contributor II
A Layer is more than a shapefile etc.. The layer holds a link to the file and other information (symbology, selection, etc.).
Calling SelectLayerByLocation_management(...) with a file (select_features-parameter, r"C:/Test/test.shp" e.g.) will use this file without any selection.
Using the Layer name solves the problem.
To select features from your file in arcpy you first have to call MakeFeatureLayer_management.
Oh, dont forget to avoid multiple layers with the same name in your TOC. ArcGIS will use the first one with the right name! A grouplayer should help to.
0 Kudos