Definition Queries on map layers in Pro don't appear to allow spatial queries. So I thought I'd try using a Query Layer instead. These require the query be written in SQL. But I'm not finding any example of spatial queries in SQL reference for query expressions used in ArcGIS—ArcGIS Pro | Documentation So I'm thinking maybe Query Layers don't support spatial queries either.
Is that the case? And if so, anyone know the best way to create a map layer that conforms to a spatial query? It's a simple query - points in the layer need to be inside a polygon in another layer.
Hello Angela,
Based on the research I've done thus far it there doesn't seem to be built-in Spatial Query functionality. There is a thread for this on the ArcGIS Ideas page though. I would recommend up voting this idea in an effort to grant it additional traction.
https://community.esri.com/ideas/1426
A lot of the workarounds I've found to achieve this functionality involve custom scripts which can become complicated depending on your level of expertise. However, being that you are just trying to display point features within a certain polygon boundary, there is an easy and straight forward method that allows you to do this. All you need to do is go into the 'Map Properties' > 'Clip Layers' > 'Clip to the outline of features' > Specify polygon feature class. Then go down to 'Exclude layers from clipping' and check everything except for the point feature class that you want to be within the polygons.
I hope this helps!
Lukas
Unfortunately, this solution doesn't seem to have any effect on the records in the map - only what's displayed. Is there a way to have it exclude the clipped features from the table - either in Pro or when the map is published in Portal?
I don't believe the Clip Layer functionality deals with the records but more so with what is displayed. If you want to only show records within those polygons and exclude all others from the attribute table wouldn't a select by location and then exporting the selected records be the best option? Is there something that is preventing you from wanting to do this? Creating a new layer which only contains what you want would be like a more permanent version of what a definition query would do.
Let me know what you think!
Lukas
I'll see if I can accomplish this in Portal using Analysis > Overlay Layers.
I think I see what the seeking to do and there was a way in ArcMap to add a subquery inside the definition query if both feature classes lived in an enterprise geodatabase. I attempted this in Pro and it does validate the query but on saving it, it never applies. Then, when you open up the definition query editor, it shows no active definition queries. So I agree with your desire and others that it would be nice to have a way to limit the features by a spatial definition query.