Exporting feature class into multiple feature classes based on field values using ArcGIS Desktop?Single polygon shapefile to multiple polygon shapefilesSplitting feature class by unique values for an attribute/field in ArcGIS for Desktop?Dividing polygon layer into multiple layers by values in attribute table column using ArcGIS for Desktop?How to separate states in USA file using ArcGIS for Desktop?Export to SHP with ArcPy with queryCreating new feature classes from rows in polygon feature class?Automating Extract by Attribute using ArcGIS ModelBuilder?Iterating/looping through Select by Attributes and Export Data?Use python code to extract all attributes shapefilecreating many Shapefiles from from a single multi-polygonal shapefile using ArGIS toolsDeleting records from multiple, similar feature classes by attribute values using SQL statement in ArcGIS Desktop?Creating individual points from count field in point feature class using ArcGIS for Desktop?Create New Feature Class Based off Multiple Feature ClassesSimplifying a feature class to feature class ETL using multiple input feature classes with varied schemasCombining multiple feature classes into single feature class using ArcGIS for Desktop?Merging several feature classes into one pre-existing feature class in geodatabase with coded domains?Bulk Exporting Feature Classes Based on Field Name in ArcGIS Desktop?Appending multiple shapefiles into existing blank feature classes using ModelBuilder?Aligning or integrating features from two feature classes using ArcGIS Desktop?Exporting multiple feature classes with joined fields using ArcPy?
What is it called when one voice type sings a 'solo'?
What are the advantages and disadvantages of running one shots compared to campaigns?
What happens when a metallic dragon and a chromatic dragon mate?
Landing in very high winds
Is it wise to hold on to stock that has plummeted and then stabilized?
Manga about a female worker who got dragged into another world together with this high school girl and she was just told she's not needed anymore
How to manage monthly salary
extract characters between two commas?
Is domain driven design an anti-SQL pattern?
How to answer pointed "are you quitting" questioning when I don't want them to suspect
Shall I use personal or official e-mail account when registering to external websites for work purpose?
Copycat chess is back
Add an angle to a sphere
Doomsday-clock for my fantasy planet
"My colleague's body is amazing"
How would photo IDs work for shapeshifters?
Where else does the Shulchan Aruch quote an authority by name?
Finding files for which a command fails
Can I legally use front facing blue light in the UK?
What is the offset in a seaplane's hull?
Is there any use for defining additional entity types in a SOQL FROM clause?
Is there a way to make member function NOT callable from constructor?
Could Giant Ground Sloths have been a good pack animal for the ancient Mayans?
Calculate Levenshtein distance between two strings in Python
Exporting feature class into multiple feature classes based on field values using ArcGIS Desktop?
Single polygon shapefile to multiple polygon shapefilesSplitting feature class by unique values for an attribute/field in ArcGIS for Desktop?Dividing polygon layer into multiple layers by values in attribute table column using ArcGIS for Desktop?How to separate states in USA file using ArcGIS for Desktop?Export to SHP with ArcPy with queryCreating new feature classes from rows in polygon feature class?Automating Extract by Attribute using ArcGIS ModelBuilder?Iterating/looping through Select by Attributes and Export Data?Use python code to extract all attributes shapefilecreating many Shapefiles from from a single multi-polygonal shapefile using ArGIS toolsDeleting records from multiple, similar feature classes by attribute values using SQL statement in ArcGIS Desktop?Creating individual points from count field in point feature class using ArcGIS for Desktop?Create New Feature Class Based off Multiple Feature ClassesSimplifying a feature class to feature class ETL using multiple input feature classes with varied schemasCombining multiple feature classes into single feature class using ArcGIS for Desktop?Merging several feature classes into one pre-existing feature class in geodatabase with coded domains?Bulk Exporting Feature Classes Based on Field Name in ArcGIS Desktop?Appending multiple shapefiles into existing blank feature classes using ModelBuilder?Aligning or integrating features from two feature classes using ArcGIS Desktop?Exporting multiple feature classes with joined fields using ArcPy?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a feature class with over 2,000 features, and I need to make them all individual feature classes based on a field.
Is there a way to do this?
arcgis-desktop select-by-attribute split-by-attribute
add a comment |
I have a feature class with over 2,000 features, and I need to make them all individual feature classes based on a field.
Is there a way to do this?
arcgis-desktop select-by-attribute split-by-attribute
1
And are you really sure that you need this 4178 shapefiles? Sounds like bad solution. Why are you need this?
– Serge Norin
Nov 9 '17 at 21:34
I agree with @SergeNorin. A definition query would be much easier, and have the same effect.
– Bjorn
Nov 9 '17 at 21:47
See @SergeNorin's linked answer, this is exactly what you're asking for. But that sounds a bit unnecessarily complex, you should probably go for either a simple definition query in your layer properties, or else an Iterator process or Search Cursor.
– AlecZ
Nov 9 '17 at 22:02
add a comment |
I have a feature class with over 2,000 features, and I need to make them all individual feature classes based on a field.
Is there a way to do this?
arcgis-desktop select-by-attribute split-by-attribute
I have a feature class with over 2,000 features, and I need to make them all individual feature classes based on a field.
Is there a way to do this?
arcgis-desktop select-by-attribute split-by-attribute
arcgis-desktop select-by-attribute split-by-attribute
edited Apr 14 '18 at 20:05
PolyGeo♦
53.9k1781245
53.9k1781245
asked May 19 '11 at 22:32
SophieSophie
163124
163124
1
And are you really sure that you need this 4178 shapefiles? Sounds like bad solution. Why are you need this?
– Serge Norin
Nov 9 '17 at 21:34
I agree with @SergeNorin. A definition query would be much easier, and have the same effect.
– Bjorn
Nov 9 '17 at 21:47
See @SergeNorin's linked answer, this is exactly what you're asking for. But that sounds a bit unnecessarily complex, you should probably go for either a simple definition query in your layer properties, or else an Iterator process or Search Cursor.
– AlecZ
Nov 9 '17 at 22:02
add a comment |
1
And are you really sure that you need this 4178 shapefiles? Sounds like bad solution. Why are you need this?
– Serge Norin
Nov 9 '17 at 21:34
I agree with @SergeNorin. A definition query would be much easier, and have the same effect.
– Bjorn
Nov 9 '17 at 21:47
See @SergeNorin's linked answer, this is exactly what you're asking for. But that sounds a bit unnecessarily complex, you should probably go for either a simple definition query in your layer properties, or else an Iterator process or Search Cursor.
– AlecZ
Nov 9 '17 at 22:02
1
1
And are you really sure that you need this 4178 shapefiles? Sounds like bad solution. Why are you need this?
– Serge Norin
Nov 9 '17 at 21:34
And are you really sure that you need this 4178 shapefiles? Sounds like bad solution. Why are you need this?
– Serge Norin
Nov 9 '17 at 21:34
I agree with @SergeNorin. A definition query would be much easier, and have the same effect.
– Bjorn
Nov 9 '17 at 21:47
I agree with @SergeNorin. A definition query would be much easier, and have the same effect.
– Bjorn
Nov 9 '17 at 21:47
See @SergeNorin's linked answer, this is exactly what you're asking for. But that sounds a bit unnecessarily complex, you should probably go for either a simple definition query in your layer properties, or else an Iterator process or Search Cursor.
– AlecZ
Nov 9 '17 at 22:02
See @SergeNorin's linked answer, this is exactly what you're asking for. But that sounds a bit unnecessarily complex, you should probably go for either a simple definition query in your layer properties, or else an Iterator process or Search Cursor.
– AlecZ
Nov 9 '17 at 22:02
add a comment |
15 Answers
15
active
oldest
votes
You may use the Split By Attributes tool:
Splits an input dataset by unique attributes
There are versions available for:
ArcGIS Pro (available at all license levels)
ArcGIS Desktop 10.6 (available at all license levels)- USGS versions (Split By Attribute Tool)
add a comment |
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:
Perhaps I am novice with Model Builder (much better with Python) but I want to give this a shot... I keep running into the error that the table already exists. If I group features by an attribute, then output to that selected unique value, and use the variable in my output name, then what could I be doing wrong?
– Stella
Feb 18 '16 at 18:41
I would imagine it's the output name that is wrong,are you using inline substitution as shown in the image?
– Hornbydd
Feb 18 '16 at 18:47
is this tool is supported in Basic licence?
– Losbaltica
Jan 25 '17 at 14:09
You can build all that you can see in the model with a basic license.
– Hornbydd
Jan 25 '17 at 17:06
add a comment |
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 IDLE (the python GUI) create a new file, and copy the code below. After adapting the code for your my_shapefile, outputdir and my_attribute it should work.
# Script created to separate one shapefile in multiple ones by one specific
# attribute
# Example for a Inputfile called "my_shapefile" and a field called "my_attribute"
import arcgisscripting
# Starts Geoprocessing
gp = arcgisscripting.create(9.3)
gp.OverWriteOutput = 1
#Set Input Output variables
inputFile = u"C:\GISTemp\My_Shapefile.shp" #<-- CHANGE
outDir = u"C:\GISTemp\" #<-- CHANGE
# Reads My_shapefile for different values in the attribute
rows = gp.searchcursor(inputFile)
row = rows.next()
attribute_types = set([])
while row:
attribute_types.add(row.my_attribute) #<-- CHANGE my_attribute to the name of your attribute
row = rows.next()
# Output a Shapefile for each different attribute
for each_attribute in attribute_types:
outSHP = outDir + each_attribute + u".shp"
print outSHP
gp.Select_analysis (inputFile, outSHP, ""my_attribute" = '" + each_attribute + "'") #<-- CHANGE my_attribute to the name of your attribute
del rows, row, attribute_types, gp
#END
add a comment |
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.
Example Code:
import arcpy
arcpy.env.workspace = "c:/data"
arcpy.Split_analysis("Habitat_Analysis.gdb/vegtype", "climate.shp", "Zone",
"C:/output/Output.gdb", "1 Meters")
The built-in Split tool works great for your purposes if you create an extent rectangle the same size as your polygons you wish to split.
– ccn
Jan 31 '13 at 16:25
Unless I'm misreading the question I think it is asking for a "Split By Attribute" rather than a "Split By Location". Split (Analysis) provides "Split By Location" functionality. The comment by @ccn here offers an interesting workaround which could perhaps be edited in as a "clarification" to this answer.
– PolyGeo♦
Dec 3 '14 at 6:39
I worry that the question describesSplit By Attribute
functionality and your answer is mostly aboutSplit [By Geometry]
.
– PolyGeo♦
Jul 27 '17 at 22:56
add a comment |
I used Alexandre Neto'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
# attribute
# Example for a Inputfile called "my_shapefile" and a field called "my_attribute"
import arcpy
#Set Input Output variables
inputFile = u"D:DXF-Exportmy_shapefile.shp" #<-- CHANGE
outDir = u"D:DXF-Export\" #<-- CHANGE
# Reads My_shapefile for different values in the attribute
rows = arcpy.SearchCursor(inputFile)
row = rows.next()
attribute_types = set([])
while row:
attribute_types.add(row.my_attribute) #<-- CHANGE my_attribute to the name of your attribute
row = rows.next()
# Output a Shapefile for each different attribute
for each_attribute in attribute_types:
outSHP = outDir + each_attribute + u".shp"
print outSHP
arcpy.Select_analysis (inputFile, outSHP, ""my_attribute" = '" + each_attribute + "'") #<-- CHANGE my_attribute to the name of your attribute
del rows, row, attribute_types
#END
add a comment |
This is an even easier way to do this... and it outputs into a GDB.
http://www.umesc.usgs.gov/management/dss/split_by_attribute_tool.html
download the tool from USGS, took me 3 minutes to do what i had been trying for 1 hour.
Thank you for the link! Works like a charm (and for version 10.2!)
– WolverineTime
Mar 26 '15 at 17:07
I tried this tool recently, and nothing happened when I executed it. I chose my feature, selected the field to select features by, selected an output location, hit OK and nothing happened. It just wouldn't "go"...am I missing something? Thanks!
– rachel.passer
May 28 '15 at 15:09
add a comment |
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 a folder of your choice.
import arcpy, re
arcpy.env.overwriteOutput = True
Input = arcpy.GetParameterAsText(0)
Flds = "%s" % (arcpy.GetParameterAsText(1))
OutWorkspace = arcpy.GetParameterAsText(2)
myre = re.compile(";")
FldsSplit = myre.split(Flds)
sort = "%s A" % (FldsSplit[0])
rows = arcpy.SearchCursor(Input, "", "", Flds, sort)
for row in rows:
var = []
for r in range(len(FldsSplit)):
var.append(row.getValue(FldsSplit[r]))
Query = ''
Name = ''
for x in range(len(var)):
if x == 0:
fildz = FldsSplit[x]
Name = var[x] + "_"
Query += (""" "%s" = '%s'""" % (fildz, var[x]))
if x > 0:
fildz = FldsSplit[x]
Name += var[x] + "_"
Query += (""" AND "%s" = '%s' """ % (fildz, var[x]))
OutputShp = OutWorkspace + r"%s.shp" % (Name)
arcpy.Select_analysis(Input, OutputShp, Query)
add a comment |
Split Dataset from GME is a free third-party tool that splits by attribute.
We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.
add a comment |
I have eventually got it working with SearchCursor and Select_analysis
arcpy.env.workspace = strInPath
# create a set to hold the attributes
attributes=set([])
# ---- create a list of feature classes in the current workspace ----
listOfFeatures = arcpy.SearchCursor(strInPath,"","",strFieldName,"")
for row in listOfFeatures:
attributes.add(row.getValue(strFieldName))
count=1
try:
for row in attributes:
stroOutputClass = strBaseName + "_" +str(count)# (str(row.getValue(strFieldName))).replace('/','_')
strOutputFeatureClass = os.path.join(strOutGDBPath, stroOutputClass)
arcpy.Select_analysis(strInPath,strOutputFeatureClass,strQueryExp)#"["+strFieldName+"]"+"='"+row+"'")
count=count+1
del attributes
except:
arcpy.AddMessage('Error found')
add a comment |
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)
# Description:
# ---------------------------------------------------------------------------
# Import arcpy module
import arcpy
# Load required toolboxes
arcpy.ImportToolbox("Model Functions")
# Local variables:
Selected_Features = ""
Value = "1"
# Process: Iterate Feature Selection
arcpy.IterateFeatureSelection_mb("", "", "false")
add a comment |
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:
import arcpy
# This is a path to an ESRI FC of the USA
states = r'C:Program Files (x86)ArcGISDesktop10.2TemplateDataTemplateData.gdbUSAstates'
out_path = r'C:temp'
with arcpy.da.SearchCursor(states, ["STATE_NAME", "SHAPE@"]) as cursor:
for row in cursor:
out_name = str(row[0]) # Define the output shapefile name (e.g. "Hawaii")
arcpy.FeatureClassToFeatureClass_conversion(row[1], out_path, out_name)
I think the downside of this answer is that you do not carry through the attributes. I prefer an answer more like gis.stackexchange.com/a/152165/115 which will.
– PolyGeo♦
Sep 15 '16 at 22:52
Good point @PolyGeo, however, the upside is that this can be wrapped into other workflows that also requirecursor
operations.
– Aaron♦
Sep 16 '16 at 1:46
... but so could using Select_analysis in place of FeatureClassToFeatureClass - it's only one line of code that would change.
– PolyGeo♦
Sep 16 '16 at 1:51
add a comment |
You can use a geometry token (SHAPE@) within Copy Features (Data Management) to export each feature.
import arcpy, os
shp = r'C:tempyourSHP.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[0]))
arcpy.CopyFeatures_management(row[1], outfc)
add a comment |
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.
add a comment |
The "Split by Attributes" tool in the Analysis, Extract toolbox will create a new Shapefile for each unique value from the Field you select.
add a comment |
You can use a searchcursor to select each row of your file and then use copy features to export it as an individual file.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "79"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f9998%2fexporting-feature-class-into-multiple-feature-classes-based-on-field-values-usin%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
15 Answers
15
active
oldest
votes
15 Answers
15
active
oldest
votes
active
oldest
votes
active
oldest
votes
You may use the Split By Attributes tool:
Splits an input dataset by unique attributes
There are versions available for:
ArcGIS Pro (available at all license levels)
ArcGIS Desktop 10.6 (available at all license levels)- USGS versions (Split By Attribute Tool)
add a comment |
You may use the Split By Attributes tool:
Splits an input dataset by unique attributes
There are versions available for:
ArcGIS Pro (available at all license levels)
ArcGIS Desktop 10.6 (available at all license levels)- USGS versions (Split By Attribute Tool)
add a comment |
You may use the Split By Attributes tool:
Splits an input dataset by unique attributes
There are versions available for:
ArcGIS Pro (available at all license levels)
ArcGIS Desktop 10.6 (available at all license levels)- USGS versions (Split By Attribute Tool)
You may use the Split By Attributes tool:
Splits an input dataset by unique attributes
There are versions available for:
ArcGIS Pro (available at all license levels)
ArcGIS Desktop 10.6 (available at all license levels)- USGS versions (Split By Attribute Tool)
edited Aug 28 '18 at 11:45
answered May 19 '11 at 22:35
artwork21artwork21
31.1k554120
31.1k554120
add a comment |
add a comment |
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:
Perhaps I am novice with Model Builder (much better with Python) but I want to give this a shot... I keep running into the error that the table already exists. If I group features by an attribute, then output to that selected unique value, and use the variable in my output name, then what could I be doing wrong?
– Stella
Feb 18 '16 at 18:41
I would imagine it's the output name that is wrong,are you using inline substitution as shown in the image?
– Hornbydd
Feb 18 '16 at 18:47
is this tool is supported in Basic licence?
– Losbaltica
Jan 25 '17 at 14:09
You can build all that you can see in the model with a basic license.
– Hornbydd
Jan 25 '17 at 17:06
add a comment |
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:
Perhaps I am novice with Model Builder (much better with Python) but I want to give this a shot... I keep running into the error that the table already exists. If I group features by an attribute, then output to that selected unique value, and use the variable in my output name, then what could I be doing wrong?
– Stella
Feb 18 '16 at 18:41
I would imagine it's the output name that is wrong,are you using inline substitution as shown in the image?
– Hornbydd
Feb 18 '16 at 18:47
is this tool is supported in Basic licence?
– Losbaltica
Jan 25 '17 at 14:09
You can build all that you can see in the model with a basic license.
– Hornbydd
Jan 25 '17 at 17:06
add a comment |
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:
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:
answered Mar 16 '14 at 22:57
HornbyddHornbydd
27.1k32957
27.1k32957
Perhaps I am novice with Model Builder (much better with Python) but I want to give this a shot... I keep running into the error that the table already exists. If I group features by an attribute, then output to that selected unique value, and use the variable in my output name, then what could I be doing wrong?
– Stella
Feb 18 '16 at 18:41
I would imagine it's the output name that is wrong,are you using inline substitution as shown in the image?
– Hornbydd
Feb 18 '16 at 18:47
is this tool is supported in Basic licence?
– Losbaltica
Jan 25 '17 at 14:09
You can build all that you can see in the model with a basic license.
– Hornbydd
Jan 25 '17 at 17:06
add a comment |
Perhaps I am novice with Model Builder (much better with Python) but I want to give this a shot... I keep running into the error that the table already exists. If I group features by an attribute, then output to that selected unique value, and use the variable in my output name, then what could I be doing wrong?
– Stella
Feb 18 '16 at 18:41
I would imagine it's the output name that is wrong,are you using inline substitution as shown in the image?
– Hornbydd
Feb 18 '16 at 18:47
is this tool is supported in Basic licence?
– Losbaltica
Jan 25 '17 at 14:09
You can build all that you can see in the model with a basic license.
– Hornbydd
Jan 25 '17 at 17:06
Perhaps I am novice with Model Builder (much better with Python) but I want to give this a shot... I keep running into the error that the table already exists. If I group features by an attribute, then output to that selected unique value, and use the variable in my output name, then what could I be doing wrong?
– Stella
Feb 18 '16 at 18:41
Perhaps I am novice with Model Builder (much better with Python) but I want to give this a shot... I keep running into the error that the table already exists. If I group features by an attribute, then output to that selected unique value, and use the variable in my output name, then what could I be doing wrong?
– Stella
Feb 18 '16 at 18:41
I would imagine it's the output name that is wrong,are you using inline substitution as shown in the image?
– Hornbydd
Feb 18 '16 at 18:47
I would imagine it's the output name that is wrong,are you using inline substitution as shown in the image?
– Hornbydd
Feb 18 '16 at 18:47
is this tool is supported in Basic licence?
– Losbaltica
Jan 25 '17 at 14:09
is this tool is supported in Basic licence?
– Losbaltica
Jan 25 '17 at 14:09
You can build all that you can see in the model with a basic license.
– Hornbydd
Jan 25 '17 at 17:06
You can build all that you can see in the model with a basic license.
– Hornbydd
Jan 25 '17 at 17:06
add a comment |
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 IDLE (the python GUI) create a new file, and copy the code below. After adapting the code for your my_shapefile, outputdir and my_attribute it should work.
# Script created to separate one shapefile in multiple ones by one specific
# attribute
# Example for a Inputfile called "my_shapefile" and a field called "my_attribute"
import arcgisscripting
# Starts Geoprocessing
gp = arcgisscripting.create(9.3)
gp.OverWriteOutput = 1
#Set Input Output variables
inputFile = u"C:\GISTemp\My_Shapefile.shp" #<-- CHANGE
outDir = u"C:\GISTemp\" #<-- CHANGE
# Reads My_shapefile for different values in the attribute
rows = gp.searchcursor(inputFile)
row = rows.next()
attribute_types = set([])
while row:
attribute_types.add(row.my_attribute) #<-- CHANGE my_attribute to the name of your attribute
row = rows.next()
# Output a Shapefile for each different attribute
for each_attribute in attribute_types:
outSHP = outDir + each_attribute + u".shp"
print outSHP
gp.Select_analysis (inputFile, outSHP, ""my_attribute" = '" + each_attribute + "'") #<-- CHANGE my_attribute to the name of your attribute
del rows, row, attribute_types, gp
#END
add a comment |
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 IDLE (the python GUI) create a new file, and copy the code below. After adapting the code for your my_shapefile, outputdir and my_attribute it should work.
# Script created to separate one shapefile in multiple ones by one specific
# attribute
# Example for a Inputfile called "my_shapefile" and a field called "my_attribute"
import arcgisscripting
# Starts Geoprocessing
gp = arcgisscripting.create(9.3)
gp.OverWriteOutput = 1
#Set Input Output variables
inputFile = u"C:\GISTemp\My_Shapefile.shp" #<-- CHANGE
outDir = u"C:\GISTemp\" #<-- CHANGE
# Reads My_shapefile for different values in the attribute
rows = gp.searchcursor(inputFile)
row = rows.next()
attribute_types = set([])
while row:
attribute_types.add(row.my_attribute) #<-- CHANGE my_attribute to the name of your attribute
row = rows.next()
# Output a Shapefile for each different attribute
for each_attribute in attribute_types:
outSHP = outDir + each_attribute + u".shp"
print outSHP
gp.Select_analysis (inputFile, outSHP, ""my_attribute" = '" + each_attribute + "'") #<-- CHANGE my_attribute to the name of your attribute
del rows, row, attribute_types, gp
#END
add a comment |
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 IDLE (the python GUI) create a new file, and copy the code below. After adapting the code for your my_shapefile, outputdir and my_attribute it should work.
# Script created to separate one shapefile in multiple ones by one specific
# attribute
# Example for a Inputfile called "my_shapefile" and a field called "my_attribute"
import arcgisscripting
# Starts Geoprocessing
gp = arcgisscripting.create(9.3)
gp.OverWriteOutput = 1
#Set Input Output variables
inputFile = u"C:\GISTemp\My_Shapefile.shp" #<-- CHANGE
outDir = u"C:\GISTemp\" #<-- CHANGE
# Reads My_shapefile for different values in the attribute
rows = gp.searchcursor(inputFile)
row = rows.next()
attribute_types = set([])
while row:
attribute_types.add(row.my_attribute) #<-- CHANGE my_attribute to the name of your attribute
row = rows.next()
# Output a Shapefile for each different attribute
for each_attribute in attribute_types:
outSHP = outDir + each_attribute + u".shp"
print outSHP
gp.Select_analysis (inputFile, outSHP, ""my_attribute" = '" + each_attribute + "'") #<-- CHANGE my_attribute to the name of your attribute
del rows, row, attribute_types, gp
#END
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 IDLE (the python GUI) create a new file, and copy the code below. After adapting the code for your my_shapefile, outputdir and my_attribute it should work.
# Script created to separate one shapefile in multiple ones by one specific
# attribute
# Example for a Inputfile called "my_shapefile" and a field called "my_attribute"
import arcgisscripting
# Starts Geoprocessing
gp = arcgisscripting.create(9.3)
gp.OverWriteOutput = 1
#Set Input Output variables
inputFile = u"C:\GISTemp\My_Shapefile.shp" #<-- CHANGE
outDir = u"C:\GISTemp\" #<-- CHANGE
# Reads My_shapefile for different values in the attribute
rows = gp.searchcursor(inputFile)
row = rows.next()
attribute_types = set([])
while row:
attribute_types.add(row.my_attribute) #<-- CHANGE my_attribute to the name of your attribute
row = rows.next()
# Output a Shapefile for each different attribute
for each_attribute in attribute_types:
outSHP = outDir + each_attribute + u".shp"
print outSHP
gp.Select_analysis (inputFile, outSHP, ""my_attribute" = '" + each_attribute + "'") #<-- CHANGE my_attribute to the name of your attribute
del rows, row, attribute_types, gp
#END
edited Jun 25 '15 at 6:09
answered Dec 20 '12 at 11:42
Alexandre NetoAlexandre Neto
10.3k23863
10.3k23863
add a comment |
add a comment |
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.
Example Code:
import arcpy
arcpy.env.workspace = "c:/data"
arcpy.Split_analysis("Habitat_Analysis.gdb/vegtype", "climate.shp", "Zone",
"C:/output/Output.gdb", "1 Meters")
The built-in Split tool works great for your purposes if you create an extent rectangle the same size as your polygons you wish to split.
– ccn
Jan 31 '13 at 16:25
Unless I'm misreading the question I think it is asking for a "Split By Attribute" rather than a "Split By Location". Split (Analysis) provides "Split By Location" functionality. The comment by @ccn here offers an interesting workaround which could perhaps be edited in as a "clarification" to this answer.
– PolyGeo♦
Dec 3 '14 at 6:39
I worry that the question describesSplit By Attribute
functionality and your answer is mostly aboutSplit [By Geometry]
.
– PolyGeo♦
Jul 27 '17 at 22:56
add a comment |
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.
Example Code:
import arcpy
arcpy.env.workspace = "c:/data"
arcpy.Split_analysis("Habitat_Analysis.gdb/vegtype", "climate.shp", "Zone",
"C:/output/Output.gdb", "1 Meters")
The built-in Split tool works great for your purposes if you create an extent rectangle the same size as your polygons you wish to split.
– ccn
Jan 31 '13 at 16:25
Unless I'm misreading the question I think it is asking for a "Split By Attribute" rather than a "Split By Location". Split (Analysis) provides "Split By Location" functionality. The comment by @ccn here offers an interesting workaround which could perhaps be edited in as a "clarification" to this answer.
– PolyGeo♦
Dec 3 '14 at 6:39
I worry that the question describesSplit By Attribute
functionality and your answer is mostly aboutSplit [By Geometry]
.
– PolyGeo♦
Jul 27 '17 at 22:56
add a comment |
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.
Example Code:
import arcpy
arcpy.env.workspace = "c:/data"
arcpy.Split_analysis("Habitat_Analysis.gdb/vegtype", "climate.shp", "Zone",
"C:/output/Output.gdb", "1 Meters")
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.
Example Code:
import arcpy
arcpy.env.workspace = "c:/data"
arcpy.Split_analysis("Habitat_Analysis.gdb/vegtype", "climate.shp", "Zone",
"C:/output/Output.gdb", "1 Meters")
edited Jul 27 '17 at 22:55
PolyGeo♦
53.9k1781245
53.9k1781245
answered Dec 20 '12 at 8:11
AragonAragon
20.4k34999
20.4k34999
The built-in Split tool works great for your purposes if you create an extent rectangle the same size as your polygons you wish to split.
– ccn
Jan 31 '13 at 16:25
Unless I'm misreading the question I think it is asking for a "Split By Attribute" rather than a "Split By Location". Split (Analysis) provides "Split By Location" functionality. The comment by @ccn here offers an interesting workaround which could perhaps be edited in as a "clarification" to this answer.
– PolyGeo♦
Dec 3 '14 at 6:39
I worry that the question describesSplit By Attribute
functionality and your answer is mostly aboutSplit [By Geometry]
.
– PolyGeo♦
Jul 27 '17 at 22:56
add a comment |
The built-in Split tool works great for your purposes if you create an extent rectangle the same size as your polygons you wish to split.
– ccn
Jan 31 '13 at 16:25
Unless I'm misreading the question I think it is asking for a "Split By Attribute" rather than a "Split By Location". Split (Analysis) provides "Split By Location" functionality. The comment by @ccn here offers an interesting workaround which could perhaps be edited in as a "clarification" to this answer.
– PolyGeo♦
Dec 3 '14 at 6:39
I worry that the question describesSplit By Attribute
functionality and your answer is mostly aboutSplit [By Geometry]
.
– PolyGeo♦
Jul 27 '17 at 22:56
The built-in Split tool works great for your purposes if you create an extent rectangle the same size as your polygons you wish to split.
– ccn
Jan 31 '13 at 16:25
The built-in Split tool works great for your purposes if you create an extent rectangle the same size as your polygons you wish to split.
– ccn
Jan 31 '13 at 16:25
Unless I'm misreading the question I think it is asking for a "Split By Attribute" rather than a "Split By Location". Split (Analysis) provides "Split By Location" functionality. The comment by @ccn here offers an interesting workaround which could perhaps be edited in as a "clarification" to this answer.
– PolyGeo♦
Dec 3 '14 at 6:39
Unless I'm misreading the question I think it is asking for a "Split By Attribute" rather than a "Split By Location". Split (Analysis) provides "Split By Location" functionality. The comment by @ccn here offers an interesting workaround which could perhaps be edited in as a "clarification" to this answer.
– PolyGeo♦
Dec 3 '14 at 6:39
I worry that the question describes
Split By Attribute
functionality and your answer is mostly about Split [By Geometry]
.– PolyGeo♦
Jul 27 '17 at 22:56
I worry that the question describes
Split By Attribute
functionality and your answer is mostly about Split [By Geometry]
.– PolyGeo♦
Jul 27 '17 at 22:56
add a comment |
I used Alexandre Neto'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
# attribute
# Example for a Inputfile called "my_shapefile" and a field called "my_attribute"
import arcpy
#Set Input Output variables
inputFile = u"D:DXF-Exportmy_shapefile.shp" #<-- CHANGE
outDir = u"D:DXF-Export\" #<-- CHANGE
# Reads My_shapefile for different values in the attribute
rows = arcpy.SearchCursor(inputFile)
row = rows.next()
attribute_types = set([])
while row:
attribute_types.add(row.my_attribute) #<-- CHANGE my_attribute to the name of your attribute
row = rows.next()
# Output a Shapefile for each different attribute
for each_attribute in attribute_types:
outSHP = outDir + each_attribute + u".shp"
print outSHP
arcpy.Select_analysis (inputFile, outSHP, ""my_attribute" = '" + each_attribute + "'") #<-- CHANGE my_attribute to the name of your attribute
del rows, row, attribute_types
#END
add a comment |
I used Alexandre Neto'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
# attribute
# Example for a Inputfile called "my_shapefile" and a field called "my_attribute"
import arcpy
#Set Input Output variables
inputFile = u"D:DXF-Exportmy_shapefile.shp" #<-- CHANGE
outDir = u"D:DXF-Export\" #<-- CHANGE
# Reads My_shapefile for different values in the attribute
rows = arcpy.SearchCursor(inputFile)
row = rows.next()
attribute_types = set([])
while row:
attribute_types.add(row.my_attribute) #<-- CHANGE my_attribute to the name of your attribute
row = rows.next()
# Output a Shapefile for each different attribute
for each_attribute in attribute_types:
outSHP = outDir + each_attribute + u".shp"
print outSHP
arcpy.Select_analysis (inputFile, outSHP, ""my_attribute" = '" + each_attribute + "'") #<-- CHANGE my_attribute to the name of your attribute
del rows, row, attribute_types
#END
add a comment |
I used Alexandre Neto'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
# attribute
# Example for a Inputfile called "my_shapefile" and a field called "my_attribute"
import arcpy
#Set Input Output variables
inputFile = u"D:DXF-Exportmy_shapefile.shp" #<-- CHANGE
outDir = u"D:DXF-Export\" #<-- CHANGE
# Reads My_shapefile for different values in the attribute
rows = arcpy.SearchCursor(inputFile)
row = rows.next()
attribute_types = set([])
while row:
attribute_types.add(row.my_attribute) #<-- CHANGE my_attribute to the name of your attribute
row = rows.next()
# Output a Shapefile for each different attribute
for each_attribute in attribute_types:
outSHP = outDir + each_attribute + u".shp"
print outSHP
arcpy.Select_analysis (inputFile, outSHP, ""my_attribute" = '" + each_attribute + "'") #<-- CHANGE my_attribute to the name of your attribute
del rows, row, attribute_types
#END
I used Alexandre Neto'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
# attribute
# Example for a Inputfile called "my_shapefile" and a field called "my_attribute"
import arcpy
#Set Input Output variables
inputFile = u"D:DXF-Exportmy_shapefile.shp" #<-- CHANGE
outDir = u"D:DXF-Export\" #<-- CHANGE
# Reads My_shapefile for different values in the attribute
rows = arcpy.SearchCursor(inputFile)
row = rows.next()
attribute_types = set([])
while row:
attribute_types.add(row.my_attribute) #<-- CHANGE my_attribute to the name of your attribute
row = rows.next()
# Output a Shapefile for each different attribute
for each_attribute in attribute_types:
outSHP = outDir + each_attribute + u".shp"
print outSHP
arcpy.Select_analysis (inputFile, outSHP, ""my_attribute" = '" + each_attribute + "'") #<-- CHANGE my_attribute to the name of your attribute
del rows, row, attribute_types
#END
edited Sep 30 '15 at 8:55
Hornbydd
27.1k32957
27.1k32957
answered Jun 25 '15 at 5:55
zehpunktbarronzehpunktbarron
1,5591024
1,5591024
add a comment |
add a comment |
This is an even easier way to do this... and it outputs into a GDB.
http://www.umesc.usgs.gov/management/dss/split_by_attribute_tool.html
download the tool from USGS, took me 3 minutes to do what i had been trying for 1 hour.
Thank you for the link! Works like a charm (and for version 10.2!)
– WolverineTime
Mar 26 '15 at 17:07
I tried this tool recently, and nothing happened when I executed it. I chose my feature, selected the field to select features by, selected an output location, hit OK and nothing happened. It just wouldn't "go"...am I missing something? Thanks!
– rachel.passer
May 28 '15 at 15:09
add a comment |
This is an even easier way to do this... and it outputs into a GDB.
http://www.umesc.usgs.gov/management/dss/split_by_attribute_tool.html
download the tool from USGS, took me 3 minutes to do what i had been trying for 1 hour.
Thank you for the link! Works like a charm (and for version 10.2!)
– WolverineTime
Mar 26 '15 at 17:07
I tried this tool recently, and nothing happened when I executed it. I chose my feature, selected the field to select features by, selected an output location, hit OK and nothing happened. It just wouldn't "go"...am I missing something? Thanks!
– rachel.passer
May 28 '15 at 15:09
add a comment |
This is an even easier way to do this... and it outputs into a GDB.
http://www.umesc.usgs.gov/management/dss/split_by_attribute_tool.html
download the tool from USGS, took me 3 minutes to do what i had been trying for 1 hour.
This is an even easier way to do this... and it outputs into a GDB.
http://www.umesc.usgs.gov/management/dss/split_by_attribute_tool.html
download the tool from USGS, took me 3 minutes to do what i had been trying for 1 hour.
answered Sep 18 '14 at 17:52
David AinleyDavid Ainley
7913
7913
Thank you for the link! Works like a charm (and for version 10.2!)
– WolverineTime
Mar 26 '15 at 17:07
I tried this tool recently, and nothing happened when I executed it. I chose my feature, selected the field to select features by, selected an output location, hit OK and nothing happened. It just wouldn't "go"...am I missing something? Thanks!
– rachel.passer
May 28 '15 at 15:09
add a comment |
Thank you for the link! Works like a charm (and for version 10.2!)
– WolverineTime
Mar 26 '15 at 17:07
I tried this tool recently, and nothing happened when I executed it. I chose my feature, selected the field to select features by, selected an output location, hit OK and nothing happened. It just wouldn't "go"...am I missing something? Thanks!
– rachel.passer
May 28 '15 at 15:09
Thank you for the link! Works like a charm (and for version 10.2!)
– WolverineTime
Mar 26 '15 at 17:07
Thank you for the link! Works like a charm (and for version 10.2!)
– WolverineTime
Mar 26 '15 at 17:07
I tried this tool recently, and nothing happened when I executed it. I chose my feature, selected the field to select features by, selected an output location, hit OK and nothing happened. It just wouldn't "go"...am I missing something? Thanks!
– rachel.passer
May 28 '15 at 15:09
I tried this tool recently, and nothing happened when I executed it. I chose my feature, selected the field to select features by, selected an output location, hit OK and nothing happened. It just wouldn't "go"...am I missing something? Thanks!
– rachel.passer
May 28 '15 at 15:09
add a comment |
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 a folder of your choice.
import arcpy, re
arcpy.env.overwriteOutput = True
Input = arcpy.GetParameterAsText(0)
Flds = "%s" % (arcpy.GetParameterAsText(1))
OutWorkspace = arcpy.GetParameterAsText(2)
myre = re.compile(";")
FldsSplit = myre.split(Flds)
sort = "%s A" % (FldsSplit[0])
rows = arcpy.SearchCursor(Input, "", "", Flds, sort)
for row in rows:
var = []
for r in range(len(FldsSplit)):
var.append(row.getValue(FldsSplit[r]))
Query = ''
Name = ''
for x in range(len(var)):
if x == 0:
fildz = FldsSplit[x]
Name = var[x] + "_"
Query += (""" "%s" = '%s'""" % (fildz, var[x]))
if x > 0:
fildz = FldsSplit[x]
Name += var[x] + "_"
Query += (""" AND "%s" = '%s' """ % (fildz, var[x]))
OutputShp = OutWorkspace + r"%s.shp" % (Name)
arcpy.Select_analysis(Input, OutputShp, Query)
add a comment |
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 a folder of your choice.
import arcpy, re
arcpy.env.overwriteOutput = True
Input = arcpy.GetParameterAsText(0)
Flds = "%s" % (arcpy.GetParameterAsText(1))
OutWorkspace = arcpy.GetParameterAsText(2)
myre = re.compile(";")
FldsSplit = myre.split(Flds)
sort = "%s A" % (FldsSplit[0])
rows = arcpy.SearchCursor(Input, "", "", Flds, sort)
for row in rows:
var = []
for r in range(len(FldsSplit)):
var.append(row.getValue(FldsSplit[r]))
Query = ''
Name = ''
for x in range(len(var)):
if x == 0:
fildz = FldsSplit[x]
Name = var[x] + "_"
Query += (""" "%s" = '%s'""" % (fildz, var[x]))
if x > 0:
fildz = FldsSplit[x]
Name += var[x] + "_"
Query += (""" AND "%s" = '%s' """ % (fildz, var[x]))
OutputShp = OutWorkspace + r"%s.shp" % (Name)
arcpy.Select_analysis(Input, OutputShp, Query)
add a comment |
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 a folder of your choice.
import arcpy, re
arcpy.env.overwriteOutput = True
Input = arcpy.GetParameterAsText(0)
Flds = "%s" % (arcpy.GetParameterAsText(1))
OutWorkspace = arcpy.GetParameterAsText(2)
myre = re.compile(";")
FldsSplit = myre.split(Flds)
sort = "%s A" % (FldsSplit[0])
rows = arcpy.SearchCursor(Input, "", "", Flds, sort)
for row in rows:
var = []
for r in range(len(FldsSplit)):
var.append(row.getValue(FldsSplit[r]))
Query = ''
Name = ''
for x in range(len(var)):
if x == 0:
fildz = FldsSplit[x]
Name = var[x] + "_"
Query += (""" "%s" = '%s'""" % (fildz, var[x]))
if x > 0:
fildz = FldsSplit[x]
Name += var[x] + "_"
Query += (""" AND "%s" = '%s' """ % (fildz, var[x]))
OutputShp = OutWorkspace + r"%s.shp" % (Name)
arcpy.Select_analysis(Input, OutputShp, Query)
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 a folder of your choice.
import arcpy, re
arcpy.env.overwriteOutput = True
Input = arcpy.GetParameterAsText(0)
Flds = "%s" % (arcpy.GetParameterAsText(1))
OutWorkspace = arcpy.GetParameterAsText(2)
myre = re.compile(";")
FldsSplit = myre.split(Flds)
sort = "%s A" % (FldsSplit[0])
rows = arcpy.SearchCursor(Input, "", "", Flds, sort)
for row in rows:
var = []
for r in range(len(FldsSplit)):
var.append(row.getValue(FldsSplit[r]))
Query = ''
Name = ''
for x in range(len(var)):
if x == 0:
fildz = FldsSplit[x]
Name = var[x] + "_"
Query += (""" "%s" = '%s'""" % (fildz, var[x]))
if x > 0:
fildz = FldsSplit[x]
Name += var[x] + "_"
Query += (""" AND "%s" = '%s' """ % (fildz, var[x]))
OutputShp = OutWorkspace + r"%s.shp" % (Name)
arcpy.Select_analysis(Input, OutputShp, Query)
edited Jul 6 '15 at 21:10
PolyGeo♦
53.9k1781245
53.9k1781245
answered Sep 23 '14 at 21:01
IsaacIsaac
6114
6114
add a comment |
add a comment |
Split Dataset from GME is a free third-party tool that splits by attribute.
We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.
add a comment |
Split Dataset from GME is a free third-party tool that splits by attribute.
We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.
add a comment |
Split Dataset from GME is a free third-party tool that splits by attribute.
Split Dataset from GME is a free third-party tool that splits by attribute.
edited Nov 10 '17 at 6:01
PolyGeo♦
53.9k1781245
53.9k1781245
answered Jan 31 '13 at 16:30
ccnccn
2,7251519
2,7251519
We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.
We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.
add a comment |
add a comment |
I have eventually got it working with SearchCursor and Select_analysis
arcpy.env.workspace = strInPath
# create a set to hold the attributes
attributes=set([])
# ---- create a list of feature classes in the current workspace ----
listOfFeatures = arcpy.SearchCursor(strInPath,"","",strFieldName,"")
for row in listOfFeatures:
attributes.add(row.getValue(strFieldName))
count=1
try:
for row in attributes:
stroOutputClass = strBaseName + "_" +str(count)# (str(row.getValue(strFieldName))).replace('/','_')
strOutputFeatureClass = os.path.join(strOutGDBPath, stroOutputClass)
arcpy.Select_analysis(strInPath,strOutputFeatureClass,strQueryExp)#"["+strFieldName+"]"+"='"+row+"'")
count=count+1
del attributes
except:
arcpy.AddMessage('Error found')
add a comment |
I have eventually got it working with SearchCursor and Select_analysis
arcpy.env.workspace = strInPath
# create a set to hold the attributes
attributes=set([])
# ---- create a list of feature classes in the current workspace ----
listOfFeatures = arcpy.SearchCursor(strInPath,"","",strFieldName,"")
for row in listOfFeatures:
attributes.add(row.getValue(strFieldName))
count=1
try:
for row in attributes:
stroOutputClass = strBaseName + "_" +str(count)# (str(row.getValue(strFieldName))).replace('/','_')
strOutputFeatureClass = os.path.join(strOutGDBPath, stroOutputClass)
arcpy.Select_analysis(strInPath,strOutputFeatureClass,strQueryExp)#"["+strFieldName+"]"+"='"+row+"'")
count=count+1
del attributes
except:
arcpy.AddMessage('Error found')
add a comment |
I have eventually got it working with SearchCursor and Select_analysis
arcpy.env.workspace = strInPath
# create a set to hold the attributes
attributes=set([])
# ---- create a list of feature classes in the current workspace ----
listOfFeatures = arcpy.SearchCursor(strInPath,"","",strFieldName,"")
for row in listOfFeatures:
attributes.add(row.getValue(strFieldName))
count=1
try:
for row in attributes:
stroOutputClass = strBaseName + "_" +str(count)# (str(row.getValue(strFieldName))).replace('/','_')
strOutputFeatureClass = os.path.join(strOutGDBPath, stroOutputClass)
arcpy.Select_analysis(strInPath,strOutputFeatureClass,strQueryExp)#"["+strFieldName+"]"+"='"+row+"'")
count=count+1
del attributes
except:
arcpy.AddMessage('Error found')
I have eventually got it working with SearchCursor and Select_analysis
arcpy.env.workspace = strInPath
# create a set to hold the attributes
attributes=set([])
# ---- create a list of feature classes in the current workspace ----
listOfFeatures = arcpy.SearchCursor(strInPath,"","",strFieldName,"")
for row in listOfFeatures:
attributes.add(row.getValue(strFieldName))
count=1
try:
for row in attributes:
stroOutputClass = strBaseName + "_" +str(count)# (str(row.getValue(strFieldName))).replace('/','_')
strOutputFeatureClass = os.path.join(strOutGDBPath, stroOutputClass)
arcpy.Select_analysis(strInPath,strOutputFeatureClass,strQueryExp)#"["+strFieldName+"]"+"='"+row+"'")
count=count+1
del attributes
except:
arcpy.AddMessage('Error found')
answered May 19 '15 at 23:09
Samuel_NETSamuel_NET
665
665
add a comment |
add a comment |
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)
# Description:
# ---------------------------------------------------------------------------
# Import arcpy module
import arcpy
# Load required toolboxes
arcpy.ImportToolbox("Model Functions")
# Local variables:
Selected_Features = ""
Value = "1"
# Process: Iterate Feature Selection
arcpy.IterateFeatureSelection_mb("", "", "false")
add a comment |
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)
# Description:
# ---------------------------------------------------------------------------
# Import arcpy module
import arcpy
# Load required toolboxes
arcpy.ImportToolbox("Model Functions")
# Local variables:
Selected_Features = ""
Value = "1"
# Process: Iterate Feature Selection
arcpy.IterateFeatureSelection_mb("", "", "false")
add a comment |
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)
# Description:
# ---------------------------------------------------------------------------
# Import arcpy module
import arcpy
# Load required toolboxes
arcpy.ImportToolbox("Model Functions")
# Local variables:
Selected_Features = ""
Value = "1"
# Process: Iterate Feature Selection
arcpy.IterateFeatureSelection_mb("", "", "false")
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)
# Description:
# ---------------------------------------------------------------------------
# Import arcpy module
import arcpy
# Load required toolboxes
arcpy.ImportToolbox("Model Functions")
# Local variables:
Selected_Features = ""
Value = "1"
# Process: Iterate Feature Selection
arcpy.IterateFeatureSelection_mb("", "", "false")
answered May 19 '15 at 19:29
troubbbletroubbble
17519
17519
add a comment |
add a comment |
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:
import arcpy
# This is a path to an ESRI FC of the USA
states = r'C:Program Files (x86)ArcGISDesktop10.2TemplateDataTemplateData.gdbUSAstates'
out_path = r'C:temp'
with arcpy.da.SearchCursor(states, ["STATE_NAME", "SHAPE@"]) as cursor:
for row in cursor:
out_name = str(row[0]) # Define the output shapefile name (e.g. "Hawaii")
arcpy.FeatureClassToFeatureClass_conversion(row[1], out_path, out_name)
I think the downside of this answer is that you do not carry through the attributes. I prefer an answer more like gis.stackexchange.com/a/152165/115 which will.
– PolyGeo♦
Sep 15 '16 at 22:52
Good point @PolyGeo, however, the upside is that this can be wrapped into other workflows that also requirecursor
operations.
– Aaron♦
Sep 16 '16 at 1:46
... but so could using Select_analysis in place of FeatureClassToFeatureClass - it's only one line of code that would change.
– PolyGeo♦
Sep 16 '16 at 1:51
add a comment |
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:
import arcpy
# This is a path to an ESRI FC of the USA
states = r'C:Program Files (x86)ArcGISDesktop10.2TemplateDataTemplateData.gdbUSAstates'
out_path = r'C:temp'
with arcpy.da.SearchCursor(states, ["STATE_NAME", "SHAPE@"]) as cursor:
for row in cursor:
out_name = str(row[0]) # Define the output shapefile name (e.g. "Hawaii")
arcpy.FeatureClassToFeatureClass_conversion(row[1], out_path, out_name)
I think the downside of this answer is that you do not carry through the attributes. I prefer an answer more like gis.stackexchange.com/a/152165/115 which will.
– PolyGeo♦
Sep 15 '16 at 22:52
Good point @PolyGeo, however, the upside is that this can be wrapped into other workflows that also requirecursor
operations.
– Aaron♦
Sep 16 '16 at 1:46
... but so could using Select_analysis in place of FeatureClassToFeatureClass - it's only one line of code that would change.
– PolyGeo♦
Sep 16 '16 at 1:51
add a comment |
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:
import arcpy
# This is a path to an ESRI FC of the USA
states = r'C:Program Files (x86)ArcGISDesktop10.2TemplateDataTemplateData.gdbUSAstates'
out_path = r'C:temp'
with arcpy.da.SearchCursor(states, ["STATE_NAME", "SHAPE@"]) as cursor:
for row in cursor:
out_name = str(row[0]) # Define the output shapefile name (e.g. "Hawaii")
arcpy.FeatureClassToFeatureClass_conversion(row[1], out_path, out_name)
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:
import arcpy
# This is a path to an ESRI FC of the USA
states = r'C:Program Files (x86)ArcGISDesktop10.2TemplateDataTemplateData.gdbUSAstates'
out_path = r'C:temp'
with arcpy.da.SearchCursor(states, ["STATE_NAME", "SHAPE@"]) as cursor:
for row in cursor:
out_name = str(row[0]) # Define the output shapefile name (e.g. "Hawaii")
arcpy.FeatureClassToFeatureClass_conversion(row[1], out_path, out_name)
edited May 25 '16 at 22:45
PolyGeo♦
53.9k1781245
53.9k1781245
answered Apr 1 '14 at 19:48
Aaron♦Aaron
38.3k21110258
38.3k21110258
I think the downside of this answer is that you do not carry through the attributes. I prefer an answer more like gis.stackexchange.com/a/152165/115 which will.
– PolyGeo♦
Sep 15 '16 at 22:52
Good point @PolyGeo, however, the upside is that this can be wrapped into other workflows that also requirecursor
operations.
– Aaron♦
Sep 16 '16 at 1:46
... but so could using Select_analysis in place of FeatureClassToFeatureClass - it's only one line of code that would change.
– PolyGeo♦
Sep 16 '16 at 1:51
add a comment |
I think the downside of this answer is that you do not carry through the attributes. I prefer an answer more like gis.stackexchange.com/a/152165/115 which will.
– PolyGeo♦
Sep 15 '16 at 22:52
Good point @PolyGeo, however, the upside is that this can be wrapped into other workflows that also requirecursor
operations.
– Aaron♦
Sep 16 '16 at 1:46
... but so could using Select_analysis in place of FeatureClassToFeatureClass - it's only one line of code that would change.
– PolyGeo♦
Sep 16 '16 at 1:51
I think the downside of this answer is that you do not carry through the attributes. I prefer an answer more like gis.stackexchange.com/a/152165/115 which will.
– PolyGeo♦
Sep 15 '16 at 22:52
I think the downside of this answer is that you do not carry through the attributes. I prefer an answer more like gis.stackexchange.com/a/152165/115 which will.
– PolyGeo♦
Sep 15 '16 at 22:52
Good point @PolyGeo, however, the upside is that this can be wrapped into other workflows that also require
cursor
operations.– Aaron♦
Sep 16 '16 at 1:46
Good point @PolyGeo, however, the upside is that this can be wrapped into other workflows that also require
cursor
operations.– Aaron♦
Sep 16 '16 at 1:46
... but so could using Select_analysis in place of FeatureClassToFeatureClass - it's only one line of code that would change.
– PolyGeo♦
Sep 16 '16 at 1:51
... but so could using Select_analysis in place of FeatureClassToFeatureClass - it's only one line of code that would change.
– PolyGeo♦
Sep 16 '16 at 1:51
add a comment |
You can use a geometry token (SHAPE@) within Copy Features (Data Management) to export each feature.
import arcpy, os
shp = r'C:tempyourSHP.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[0]))
arcpy.CopyFeatures_management(row[1], outfc)
add a comment |
You can use a geometry token (SHAPE@) within Copy Features (Data Management) to export each feature.
import arcpy, os
shp = r'C:tempyourSHP.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[0]))
arcpy.CopyFeatures_management(row[1], outfc)
add a comment |
You can use a geometry token (SHAPE@) within Copy Features (Data Management) to export each feature.
import arcpy, os
shp = r'C:tempyourSHP.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[0]))
arcpy.CopyFeatures_management(row[1], outfc)
You can use a geometry token (SHAPE@) within Copy Features (Data Management) to export each feature.
import arcpy, os
shp = r'C:tempyourSHP.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[0]))
arcpy.CopyFeatures_management(row[1], outfc)
edited May 20 '15 at 11:21
answered May 19 '15 at 19:25
Aaron♦Aaron
38.3k21110258
38.3k21110258
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
edited Jul 27 '17 at 22:59
PolyGeo♦
53.9k1781245
53.9k1781245
answered May 19 '15 at 19:23
Farid CheraghiFarid Cheraghi
8,29411447
8,29411447
add a comment |
add a comment |
The "Split by Attributes" tool in the Analysis, Extract toolbox will create a new Shapefile for each unique value from the Field you select.
add a comment |
The "Split by Attributes" tool in the Analysis, Extract toolbox will create a new Shapefile for each unique value from the Field you select.
add a comment |
The "Split by Attributes" tool in the Analysis, Extract toolbox will create a new Shapefile for each unique value from the Field you select.
The "Split by Attributes" tool in the Analysis, Extract toolbox will create a new Shapefile for each unique value from the Field you select.
edited Apr 14 '18 at 20:11
PolyGeo♦
53.9k1781245
53.9k1781245
answered Nov 9 '17 at 21:53
klewisklewis
6,9351218
6,9351218
add a comment |
add a comment |
You can use a searchcursor to select each row of your file and then use copy features to export it as an individual file.
add a comment |
You can use a searchcursor to select each row of your file and then use copy features to export it as an individual file.
add a comment |
You can use a searchcursor to select each row of your file and then use copy features to export it as an individual file.
You can use a searchcursor to select each row of your file and then use copy features to export it as an individual file.
answered Nov 9 '17 at 21:44
jchestjchest
617
617
add a comment |
add a comment |
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f9998%2fexporting-feature-class-into-multiple-feature-classes-based-on-field-values-usin%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
And are you really sure that you need this 4178 shapefiles? Sounds like bad solution. Why are you need this?
– Serge Norin
Nov 9 '17 at 21:34
I agree with @SergeNorin. A definition query would be much easier, and have the same effect.
– Bjorn
Nov 9 '17 at 21:47
See @SergeNorin's linked answer, this is exactly what you're asking for. But that sounds a bit unnecessarily complex, you should probably go for either a simple definition query in your layer properties, or else an Iterator process or Search Cursor.
– AlecZ
Nov 9 '17 at 22:02