Select to view content in your preferred language

Writing a ArcPy script to create layer from selected features at end of geo-model

13553
4
08-11-2010 08:08 AM
RyanFurlong
Regular Contributor
I have created a geo-processing model that does a 14 min drive time around a point then selects all block groups within that drive time area.  As of now I have to right click in the table of contents to turn the selection into a layer while I would rather have that done automatically at the end of the model.  How do I script this in ArcPy?  I thank you in advanced for your help.
0 Kudos
4 Replies
RyanFurlong
Regular Contributor
Would it be something like this?

# Name: createlayerfromselectedfeatures.py
# Description:  creates a new layer based on a query.
# Author: RFurlong


import arcpy
from arcpy import env


arcpy.overwriteOutput = true


try:

   # Make a layer from the feature class
   arcpy.MakeFeatureLayer_management("C:/data/test.gdb/blockgroups_lyr")

   # Write the selected features to a new layer
   arcpy.CopyFeatures_management("blockgroups", "c:/data/test.gdb/blockgroups")
TimPhillips
Emerging Contributor
I have a similar problem I have created a simple model in Arcmap Arcgis9.3,  I have reached the penultimate stage which is to select polygons by location however I cannot find a tool in the system toolbox that will export the selection to a layer file. In other stages of the model i have used the select tool to export selections based on attributes but i cant seem to find a similar feature for selections based on location?

What am I missing?
0 Kudos
DaleHoneycutt
Deactivated User
There's the Save To Layer File tool.

To select features based on location, use the Select Layer By Location tool

I'm pretty sure you'll find everything you need in the Layers and Table Views toolset.
0 Kudos
JonathanQuinn
Esri Notable Contributor
Is there python script to select all of the features on the screen?  I know there is a tool for it by searching for it through the Customize menu, but is there a way to script the function?
0 Kudos