Select to view content in your preferred language

Select by Attributes creats a new layer

592
4
03-20-2024 06:26 AM
ZM258
by
New Contributor

When using the Select by Attributes tool it creates a new layer. I don't need a new layer to be created and end up removing the created layer almost immediately. Is there a way to stop the tool from creating a new layer?

0 Kudos
4 Replies
Eugene_Adkins
Frequent Contributor

I'm not encountering this issue but it may help others offer some assistance if you provide the version of Pro you're using and what sort of feature is being selected (i.e. feature class, hosted feature layer, all data regardless of source, etc.), and lastly, if you're using the geoprocessing tool or simply using the "select by attributes" tool on the map ribbon.

 

Robert_LeClair
Esri Esteemed Contributor

Whenever I see strange behavior like this, I recommend doing a soft factory reset.  You can follow the steps listed here.  Once the reset is complete, open your *.aprx and try the Select by Attributes workflow again.

0 Kudos
ZM258
by
New Contributor

I am using version 3.2.2. The feature being selected is a feature class. Also I am using the Select by attributes on the map ribbon.

0 Kudos
LauraTateosian_augori
Emerging Contributor

I'm using ArcGIS Pro 3.3 and seeing similar behavior to what was described by ZM258.  In my case, I'm calling SelectLayerByAttribute with Python from a notebook being run within ArcGIS Pro.  I could use the Python to delete the unwanted layer, but I'm also wondering if there's a way to turn this off if it's a setting or if this is 'unexpected' behavior.   Based on this conversation, I think it must be unexpected.  I don't remember it doing this before but I usually work on code outside of Pro.  I just tried running the Select layer by attribute tool  by hand (with the GUI interface) and it does not appear to add a new layer.

The code below adds 24 layers to the map.  The SelectLayerByAttribute creates a layer with a copy of the original with the current month's data selected.   The CopyFeatures creates the other 12 with only the selects, as expected.    

 

for month in range(1,13):
    where_clause = f"month='{month}'"
    temp = arcpy.management.SelectLayerByAttribute("whale_points1", "NEW_SELECTION", where_clause)
    byMonth = f"whales{month}"
    arcpy.management.CopyFeatures(temp, byMonth)

 

0 Kudos