2

I have a point feature where many points share the same value as other points on an attribute called "site". I'd like to group them by that attribute, and then make the groups into a seperate feature for each group. I'm trying the "Split By Attribute", but keep getting the Error,

'unicode' object has no attribute 'polygon'

Searching that error only gives my info on Python scripts. I thought maybe it only works on polygon layers, but I'm getting the same error when I try to spit up a layer of polygons. Does anyone have any idea what I'm doing wrong?

Below are the parameters I'm using:

Input Table

CWIRS Agreggate/CWIRS sites - point feature

Target Workspace

Scratch Geodatabase, I've also tried a directory.

Split Field

Is just a text value

enter image description here

7
  • What parameter values are you using when you try to run that tool?
    – PolyGeo
    Commented Nov 18, 2019 at 0:12
  • I edited my question to you could see what I'm doing.
    – Frank
    Commented Nov 18, 2019 at 0:42
  • Is "CWIRS Agreggate/CWIRS sites" a shapefile? I have a feeling that Split By Attributes only supports geodatabase feature classes but I'd have to check.
    – PolyGeo
    Commented Nov 18, 2019 at 0:49
  • gis.stackexchange.com/a/279724/115 suggests that any shapefile to be used as input to this tool needs to be converted to a feature class first.
    – PolyGeo
    Commented Nov 18, 2019 at 0:54
  • Rookie question here, but under in properties it says: "Data Type: Shapefile Feature Class". I guess that's not a feature class? I have other layers that say "Data Type: File Geodatabase Feature Class" , would that count as a feature class?
    – Frank
    Commented Nov 18, 2019 at 1:06

2 Answers 2

1

Tool does not work from GUI, so I tested this script from help system:

SplitByAttributes example 2 (stand-alone Python script) The following script demonstrates how to use the SplitByAttributes tool.

Name: SplitByAttributes.py

Description: Use the SplitByAttributes tool to split a feature class by unique values.

# Import required modules
import arcpy
# Set local variables
in_feature_class = 'c:/data/base.gdb/ecology'
target_workspace = 'c:/data/output.gdb'
fields = ['REGION', 'ECO_CODE']
arcpy.SplitByAttributes_analysis(in_feature_class, target_workspace, fields)

By creating:

enter image description here

With 2 relevant fields in ECOLOGY feature class:

enter image description here

Message:

Runtime error Traceback (most recent call last): File "", line 1, in File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\analysis.py", line 150, in SplitByAttributes raise e ExecuteError: 'unicode' object has no attribute 'polygon' Failed to execute (SplitByAttributes).

UPDATE: One of the reasons original script fails is in this block:

arcpy.SelectLayerByLocation_management(lyr, 'INTERSECT',arcpy.env.extent.polygon)

when environment extent set to one of ["Union of inputs","Default","Intersection.."] env.extent does not have "polygon" property, thus the error message.

also I don't understand 3rd line

    lyr = arcpy.MakeFeatureLayer_management(in_data, lyr_name)[0]
    arcpy.SelectLayerByLocation_management(lyr, 'INTERSECT',
                                           arcpy.env.extent.polygon)
    in_data = lyr_name

So I copied script to custom toolbar, pointed it to copy of original script and changed 3rd line to

in_data = lyr

Script works now with explicit declaration of extent in environment. It also works with shapefiles.

0

This tool ran fine for me and I am running ArcMap 10.7. I ran it using input data as a shapefile and a file geodatabase featureclass with output workspace being a file geodatabase. Both inputs were different geometry types (points or polygon) and were layers loaded in ArcMap when I ran the tool.

I even tried having the layers in a group layer and it ran as expected.

All my testing strongly suggests that the issue is with your data, something odd about it? As the output FeatureClass name takes on the value that you are splitting by then invalid characters will probably cause the tool to fail. I would look there first.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.