Select to view content in your preferred language

Make layer from selected features - using ArcPy

6371
12
04-05-2023 10:29 PM
ToyotaT18
Regular Contributor

In ArcGIS Pro GUI, after selecting some rows/features I can right-click the layer name in the Contents -> Selection -> Make Layer from Selected Features.

How can I achieve this using ArcPy? With the result added to the active map.

0 Kudos
12 Replies
mmetzcar
Occasional Contributor

Ohh, re-reading what was said in this post, I understand now that all I need to do is apply by selection directly when using MakeFeatureLayer using the "where_clause" parameter. So rather than making the selection first and then calling MakeFeatureLayer, I can skip the SelectLayerByAttribute and instead put that selection criteria directly into the where_clause parameter of MakeFeatureLayer. This works for my use case!

0 Kudos
DanPatterson
MVP Esteemed Contributor

check your geoprocessing options in the Project backstage to ensure that results are added to the active map.

addlayer.png


... sort of retired...
0 Kudos
ToyotaT18
Regular Contributor

Yep that's already ticked on

0 Kudos