One step forward – Two steps back

We’re on 10.4 something at work. All the times I’ve asked about upgrading to 10.5, the response is silent, which usually means no. So – I know there’s some awesome fun tools that 10.5 has built in (and that ArcPro has built in), but right now they’re out of my reach. (Ironically, I have 10.5.1 and ArcPro at home!)

Many GIS users are in a similar position. Not updating is practiced far and wide for the greater good. Instead of having our workflows be disrupted and banging our heads against the walls coming up against new mystery bugs, we just mysteriously let other people do it until we feel safe enough to get the patch and move forward. But if we’re all hesitating, then who’s actually working to fix the bugs that no one is finding?? I digress…

Split Feature by Attributes. My lord! This seems like it would have come along long ago! Now – it is in 10.5 and it is in ArcPro. Again – no 10.5 at work. Why couldn’t I use ArcPro? I could, technically. BUT – today’s goal was to figure out a way to totally automate a larger workflow that incorporated having to slip a feature into three features using attributes in a field. Basically, building this model to hand off to the IT person so we can have it run on a scheduled basis. (Which is how we gotta do things right now. So. There’s that.) So I couldn’t use the awesome tool built into ArcPro because no one else is using it.

That’s the two steps back… but below is the one step forward if you’re in the same pickle I’m in and could use a tool like this:

Split Feature by Attribute – model view
Split Feature by Attribute – toolbox view

Annddddd, here’s the code:

# Usage: splitattribute <Input_Table> <Group_By_Fields> <Output_Feature_Class> 
# Description: 
# Splits a feature into multiple features based on attributes in a field.
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy

# Load required toolboxes
arcpy.ImportToolbox("Model Functions")

# Script arguments
Input_Table = arcpy.GetParameterAsText(0)

Group_By_Fields = arcpy.GetParameterAsText(1)

Output_Feature_Class = arcpy.GetParameterAsText(2)

# Local variables:
Selected_Rows = Input_Table
Value = "1"

# Process: Iterate Row Selection
arcpy.IterateRowSelection_mb(Input_Table, Group_By_Fields, "false")

# Process: Copy Features
arcpy.CopyFeatures_management("", Output_Feature_Class, "", "0", "0", "0")

It wasn’t that long ago that I first started diving into Model Builder, and it has since become one of my favorite things.

Leave a Reply