Add a tool (w/ gui preferably) to get the attribute values for a set of selected features and use them in an interactive definition query dialog box which would allow the user to select which attributes to use for the querry and how to use them. If this is set up in gui it could also be used to visually analyse for trends within the selected data.
After selecting records manually or by location it would be great to click on a button which automatically populates these records to the definition query to either hide or show them. Often this is a tedious process.
@chris_fox-esristaff the first part of the idea is display only the selected records, but the second part is the ability to later inspect that selection and possibly alter it, as well save and share it. Copying the selection into a definition query would allow that, while creating a layer from selection does not.
Also in my experience the redraw performance of def-query layers is markedly faster than selection-set layers, especially for image services.
Hi Jakub,
How can we get your addin ?
Thanks!
Jakub:
Is this an ArcMap Addin?
If so, do you have plans to make this for Pro as well?
A further limitation of Selections that Def Queries don't have is that many operations ignore the features/rows in "Selection from layer xyz" and read straight from the source table anyway.
A tool to create a definition query that includes all selected features. Maybe using a unique identifier field like "OBJECTID". This would be a nice addition instead of having to create a new layer from selected features to see just selected features on a map.
Hi @Anonymous User I merged the idea you just submitted with this existing idea - please add your vote to this one! Thank you.
Instead of creating a new layer of the selected features it would be very helpful just to create a definition query out of the selected features (identifier = OBJECTID).
Please do this step. It's an old idea that helps avoiding data copies. Thanks a lot!
Hello,
I created an Add-in that supports the following scenario:
1) User: selects a layer in Table of Contents and makes a selection2) User: clicks on a button in the Ribbon bar (Table ->View)3) Tool: creates a new Layer Definition based on current selection (from selected layer) based on ObjectID field under a specific name 'YYYY-MM-DD HH:MM:SS'. New Layer Definition is not active.
Would that do the job?
Looking for your feedback.
Bests,
Adam
#### Edit:
If anyone is interested in, here is a link to the Add-in (ArcGIS Pro 2.8). https://www.arcgis.com/home/item.html?id=e00c7d1a38034ebd89efa194df21ae0c
####
When creating maps, I often find a situation where I need to display a few polygons on a map. Instead of performing a definition query, or selecting the features and exporting, it would be nice to have an option from right clicking a layer to "Display only selected features", instead of having to make a new layer.
For example, a cartographer only needs to show a grouping of counties. They could draw a polygon to select counties and export to a new shp/feature layer. Or They could enter the county names in a def query, only to realize counties with like names from other states are still showing right across the state boarder. This gets trickier by having to add more expressions/expression sets to exclude the state, but maybe not one county in the grouping that may also share the other state... If the cartographer could choose to "Display only selected features" in the map it would alleviate some additional workflows. They could export a map without creating new layers or making a complex def query.
An additional but similar feature, it would also be nice to have the option to filer based on map extent like in Portal or AGOL.
For what it’s worth, it's possible to do it with Python: Creating definition query from selected features using ArcGIS Pro
The script creates a definition query from the selection. It uses the first layer in the Contents pane that is called MY_USER.ROADS.def qdef_selected_features(lyr): desc = arcpy.Describe(lyr) # Get a semicolon-delimited string of selected feature IDs fid_list = desc.FIDSet.split(";") # build the query definition query = '{} IN ({})'.format(desc.OIDFieldName, ",".join(fid_list)) # apply the query definition back to the layer lyr.definitionQuery = query aprx = arcpy.mp.ArcGISProject('current') m = aprx.activeMap lyr = m.listLayers('MY_USER.ROADS')[0] qdef_selected_features(lyr)
The script creates a definition query from the selection. It uses the first layer in the Contents pane that is called MY_USER.ROADS.
def qdef_selected_features(lyr): desc = arcpy.Describe(lyr) # Get a semicolon-delimited string of selected feature IDs fid_list = desc.FIDSet.split(";") # build the query definition query = '{} IN ({})'.format(desc.OIDFieldName, ",".join(fid_list)) # apply the query definition back to the layer lyr.definitionQuery = query aprx = arcpy.mp.ArcGISProject('current') m = aprx.activeMap lyr = m.listLayers('MY_USER.ROADS')[0] qdef_selected_features(lyr)
But I think we’re all saying we’d rather have an OOTB tool.
I often use attribute queries when exploring data to figure out what's what: what features of this dataset do I want, and which ones don't I want? This is a really useful method when looking at the map and if I have an idea about what the fields are. The very next thing I do is go create a definition query that's either the same, inverse of, or similar to my selection query. To save some steps along the way, a button in the select by attributes window for 'convert to definition query' would be really helpful. I picture a prompt that asks for a definition query name, and maybe display the expression editor again in case the one you want to save is slightly different than the one you're using for your attribute query. Hit OK and the definition query is applied!
Hi @KoryKramer this actually does not seem to be the same idea. This idea, also good, seems to be talking about having the software convert selections into queries, not user-defined queries themselves within the select by attribute window. Thanks.
@wayfaringrob The workflow you described is creating a selection using an attribute query, supposedly using Select by Attributes? So you end up with a selection in the data exploration process.
"The very next thing I do is go create a definition query that's either the same, inverse of, or similar to my selection query."
Are you saying that this present idea of converting a selection to a definition query would not satisfy what you're looking for?
i.e. you just want a quick way of taking a query that you've constructed using Select by Attributes, and without making a selection, just take the query and push it into a definition query?
The comments through this idea have to do both with interactive selections (no attribute query) as well as selections made using attribute queries. The latter, which is what I understand you to be requesting, should be easier and more robust as I understand it from the development side, whereas the former (an interactive selection not based on a structured query) would have more challenges. Either way, we'd be considering both when looking at this idea.
I can check back in with the dev team on this, but in the meantime, please provide further clarification about why you feel your new idea is distinct from this existing idea.
Thank you
@KoryKramer yes -- looking for a quick way to take a query I made there, perhaps modify it a little, and use it as a definition query, regardless of what's selected. E.g. -- I take road data, and do a couple select bys on a road type field to see which values are driveways and alleys. I might want those excluded, so saving the expression as a definition query with the opportunity to change "=" to "<>" would be helpful, without copying & pasting the sql and heading to the layer properties > definition query tab to set it up. The way you're saying might be understandably trickier technically -- to have the software just invent a query (or something like it) from a selection -- probably would not suffice for reasons you probably are thinking of, too -- what field would that even use? would it be smart enough to find one? would it add a field and populate it with something shared? how would it handle new data? would it just use ObjectID? etc etc -- maybe the solution to some of that problem is just making selection layers more like definition queries where you can have multiple & turn them on and off. So for those reasons I think these are very different ideas but if you are considering them together then do what you gotta do, and thanks.
Be able to create a filter based on the selected features. For example, I'm looking at a layer that labels several polygons, but I only want a few choice ones visible. I use the select tool to select the features I don't want to see, and a filter is created to filter out those selected. This would allow for dynamic filtering based on visuals, as supposed to knowing the attributes to filter on.
I know this was mentioned previously, but I’ll say it again for clarity:
I am hoping to have the option of the query referencing a user-defined unique ID field, not just the ObjectID. For example, the tool would be able to take the selected features and output this definition query:
asset_id in (1,2,3)
Related:
@ErinKenna
Your symbology/label class workaround is interesting. Thanks.
https://community.esri.com/t5/arcgis-pro-ideas/selection-to-definition-query/idc-p/965971/highlight/true#M15087
XTools Pro 23.1 has Definition Query Switcher that contains Create definition query from selection feature. Try to use it.
@TanuHoque
If the proposed tool can be used to create a definition query on fields other than the OBJECTID, I wonder how that would work. Would you want to only allow fields that have unique values? Such as fields with a unique database index? Or maybe a field that is known to be unique due to a relationship class? (I don't use relationship classes, so I don't know)
Otherwise, if the tool were used on a non-unique field, then I don't know how a definition query could be built for the selected features.
It is important to me that the tool can be used on my user-defined ASSET_ID fields. They have unique database indexes, so I'm hoping this tool will work for them.
@TanuHoque and anyone else who's interested:
I have a working Selection to Definition query GP tool here: https://community.esri.com/t5/python-ideas/refer-to-a-specific-contents-layer-even-when-there/idi-p/1373590/highlight/true
You can either grab the Python scripts and create a GP tool yourself. Or download the .zip and simply add the tool to a project.There is currently an issue in community posts that is preventing me from attaching the .atbx file, so that's why I had to use a .zip: https://community.esri.com/t5/community-ideas/allow-attaching-a-mobile-geodatabase-as-a-file-in/idc-p/1377245/highlight/true#M536
I also included a list of requirements in the first link. You might find this requirement interesting: The tool will only generate a definition query using fields that have a unique attribute index.
Hopefully, that gives you an idea of what we're looking for. The tool works and is very handy. But of course, an OOTB tool in the UI would be better.
thanks @Bud . that is very helpful
Hello all,
It is implemented in ArcGIS Pro 3.4 release. Thank you everyone for you feedback, suggestion and even sample codes. Those were immensely helpful.
This capability is available as the new Generate Definition Query From Selection geoprocessing tool, and (as some suggested here) that is accessible directly from a layer's context menu off the Contents pane.
We appreciate you.
Please check out What's new in ArcGIS Pro 3.4 for more: https://pro.arcgis.com/en/pro-app/latest/get-started/whats-new-in-arcgis-pro.htm
@TanuHoque The docs describe a "Where Clause (Optional)" parameter.
https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/generate-definition-query-from-selection.htm
I don't see that parameter in the GP tool.
Under what circumstances would we see that parameter in the tool?
YouTube: Generating a Definition Query from a Selection in ArcGIS Pro (Esri Canada)
Connectez-vous pour publier, suivre du contenu, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.