You can achieve this with a very simple model if you have ArcGIS 10.0 or higher.
Create a model with Feature Iterator where the group by field is the attribute you wish to select by then send the output to the copy features tool using inline substitution to ensure a unique file name. The model is shown below:
I do not have access to ArcMap 10, only 9.3, but I expect that it won't be very different from this.
You can create a simple script in Python, that checks your attribute field for different values, and then, for each of them runs a SELECT operation to your original Shapefile.
If you are not familiar with python scripting, all you need to do is open you ...
Did you see Split Layer By Attributes tool updated for ArcMap 10 here? If it does not work you can use Split (Analysis) for your needs.
Splitting the Input Features creates a subset of multiple output
feature classes. The Split Field's unique values form the names of the
output feature classes. These are saved in the target workspace.
You need to use Split Vector Layer from processing toolbox. You can find the tool from Processing toolbox -> QGIS geoalgorithms -> Vector general tools -> Split Vector Layer
Select the input shapefile and use a unique ID field to save each grid block into separate file. You need to specify the output folder to save all the polygons in it.
I used @AlexandreNeto's script and updated it for ArcGIS 10.x users. Mainly you now have to import "arcpy" instead of "arcgisscripting":
# Script created to separate one shapefile in multiple ones by one specific
# Example for a Inputfile called "my_shapefile" and a field called "my_attribute"
#Set Input Output variables
Combining the script mentioned above by AkselO with model builder, I would go with the model below. Create a new field, use the field calculator to create a unique identifier (by combining fields 1, 2 and 3) then use the script to split that shapefile by the unique field value.
I know you can use an iterator in model builder, but if you prefer to use python here is something I came up with. Add the script to a toolbox with the parameters in order as Input shpfile, fields(multivalue,obtained from input), and workspace. This script will split the shapefile into multiple shapefiles based on the fields you select, and output them into ...
This is an even easier way to do this... and it outputs into a GDB.
download the tool from USGS, took me 3 minutes to do what i had been trying for 1 hour.
I have eventually got it working with SearchCursor and Select_analysis
arcpy.env.workspace = strInPath
# create a set to hold the attributes
# ---- create a list of feature classes in the current workspace ----
listOfFeatures = arcpy.SearchCursor(strInPath,"","",strFieldName,"")
for row in listOfFeatures:
Your target workspace appears to be a file geodatabase, which means your output will be feature classes. Open the Target GDB in Catalog/ArcMap and you will see the split attributes as single Feature Classes.
The documentation for the tool states the outputs are either feature classes or tables
Filtering a layer should exclude the filtered data from any analyses - that's an advantage of a filter vs just visually excluding those features with rule-based symbology. Sometimes there are bugs where filtered data is actually included, so it's safest to create a separate shapefile. There are multiple ways to do this, here are two:
The Split Vector Layer ...
Let us assume we have a buildings layer (orange polygons: A, B, C) which is linked to another layer parcel (gray polygons: 101, 102, 103) by Parcel_Num attribute field.
We can use Geometry by Expression tool in Processing Toolbox | Vector geometry.
Click on the large Epsilon mark to open an expression dialog window:
You can use a Search Cursor to loop through individual features in a feature class and write just the geometries to unique feature classes. In this example, I use a feature class of the USA and export the states to new shapefiles:
# This is a path to an ESRI FC of the USA
states = r'C:\Program Files (x86)\ArcGIS\Desktop10.2\TemplateData\...
I'm not familiar with the Iterate Feature Selection tools in ModelBuilder, but exporting just that as Python code indicate that they can be called using arcpy.
# Created on: 2015-05-19 15:26:10.00000
# (generated by ArcGIS/ModelBuilder)
# Import arcpy module
I have fallen foul to this particular tool and unsurprisingly its all about actually bothering to read the help file. A lesson I had to learn and now pass on to you...
So go to the Help file for the split by attributes tool and specifically look at the syntax section.
What is the output? It is a layer - no, is it all the layers created by the split - no, ...
It appears that the Split By Attributes tool does not currently support creating its output feature classes in a Feature Dataset.
One way to workaround that software limit would be to use an ArcPy answer to Exporting feature class into multiple feature classes based on field values using ArcGIS Desktop? as starting code to develop one.
Another is the ...
You can use a geometry token (SHAPE@) within Copy Features (Data Management) to export each feature.
import arcpy, os
shp = r'C:\temp\yourSHP.shp'
outws = r'C:\temp'
with arcpy.da.SearchCursor(shp, ["OBJECTID","SHAPE@"]) as cursor:
for row in cursor:
outfc = os.path.join(outws, "fc" + str(row))
In Arcpy, Cursors honor layer/TableView selections. According to Getting list of selected features in ArcGIS for Desktop using Python code?, you can simply iterate feature selections.
However if you want to make a selection using arcpy, use SelectLayerByAttribute_management tool.
If you have ArcGIS 10.5 and above, you can use Split By Attribute tool which will split each point based on unique attributes:
Splits an input dataset by unique attributes.
If you have older version of ArcGIS, you need to select each point manually and export. Or better, you can create your own script and loop over each point to save it to a separate ...
To do this I would create a simple Model Tool in ModelBuilder that
Adds a text field (perhaps named CLASS)
Uses a Calculate Field tool that calculates CLASS based on HEIGHT (if that is the name of your height field) with the Python Parser
if height < 3:
elif 6 < height < 0.645051:
One solution would be to create a new field named ID or something similar. Then Calculate Field and set it equal to OBJECTID, which does show up in the field calculator. Then you can use the new ID field as the Split Field in the Split By Attributes tool.
The provided/accepted answer explains the behavior. This answer provides a possible workaround.
As Split by Attributes is a Script tool, you can hack it a little bit. (I don't have 10.5 to test if this change will 'just work', but I know the hack will get you the behavior you want: to set the output in the tool to a feature dataset).
With ArcToolbox or the ...
The split by attributes tool does not require a loop; you can just specify the output location and the criteria for splitting, per the documentation: http://desktop.arcgis.com/en/arcmap/latest/tools/analysis-toolbox/split-by-attributes.htm
Your initial code using the loop would give an error due to arcpy.SplitByAttributes_analysis not returning a list (it ...
This is some working code that I have modified (simplified) to suit your purpose, the original is more generic but may be confusing:
import os, sys, arcpy
InShp = "c:/temp/folder/shapefile.shp" # from your values
OutFolder = "c:/temp/folder"
Field = "NAME"
UValues =  # an empty list, then recurse and add each unique value
I am unable to reproduce your problem, and your graphic does not show your tool dialog in its entirety which might enable me to do a more nuanced test.
When I use the Search window to find and open the Split By Attributes tool using ArcGIS Desktop 10.6 on Windows 7 SP1 it opens with a green dot next to the Input Table as you can see below:
If you are ...