I have a polygon containing lots of bodies of water and only want to display the bodies of water over a certain size.

Can I do this using a definition query?

  • 4
    Do you want to just label bodies of water when they're over a certain size, or do you want to only show bodies of water over a certain size? Your question title and question imply the latter, but your code implies the former. – recurvata Oct 7 '15 at 15:44
  • I want to only show bodies of water over a certain size. My code could be way off. – Anthony Stokes Oct 8 '15 at 16:31
  • I was attempting to do it in the Display Expression box under the Display tab of the Layer properties in ArcMap 10.3. Is it possible to do it there? – Anthony Stokes Oct 8 '15 at 17:28
  • @AnthonyStokes I am fairly certain that is for something different. What you want is a Definition Query. The Definition Query tab uses SQL not python functions like you have in your code example. Edit the question to use the term Definition Query and I can give you a full fledged answer:-) – GeoSharp Oct 8 '15 at 17:32

It is my understanding you cannot directly perform spatial queries in the Defintion Query tab. However because ESRI offers a calculate geometry option for common shapefile geometry calculations and automatically calculates area for feature classes, you can do a psuedo spatial query on a field containing the value of area for each polygon. For shapefiles the workflow is as follows:

  • add a field to your feature class and name it, for example, 'Area'
  • right click that field and select Calculate Geometry
  • calculate area with with the dialog box that comes up. See screenshot:

enter image description here

  • Then in the Definition Query tab use an expression like "Area" > 50 to only show features larger than 50 sq m. See image below:

enter image description here

For feature classes use the automatically calculated field for area in a Definition Query.

  • 2
    Note that you only need to add the new field if you are using a shapefile. Feature classes have shape dimension fields that are automatically generated and updated with editing. And they are supported in def queries. – Paul Oct 8 '15 at 18:37
  • @Paul Thanks. I have updated the answer to include that information. – GeoSharp Oct 8 '15 at 18:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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