I am have a feature class of thousands of cities, however sometimes the cities are not a single polygon and instead have small fragments separate, with their own object ID, but the same name field.

I was trying to label the cities so that it would only pull the largest one (Shape.STArea() is the name for volume in my database) of each city name (NAME is the attribute for city name).

I don't have any formal programing experience, and got as far as creating a query to only label the single largest attribute by doing:

Shape.STArea() =(SELECT MAX( Shape.STArea() ) FROM DBO.CityArea)

However I couldn't figure out how to do this for each "NAME" I was tinkering with loops but I couldn't seem to get anything to work.

Note: none of the cities have the same name other than the fragments, and unfortunately I can't export or change the data, as it is not mine, and I am making layer files for our DPW who all pull from this database.

  • 1
    Do you have the maplex label engine? I thik it comes with advanced license. It has an option of labeling only the largest part desktop.arcgis.com/en/arcmap/10.3/map/working-with-text/… but that might require dissolving the polygons... You could use an advanced (python) label expression but that too comes with limitations. Feb 28 '17 at 22:47

If the language you are writing in in PostgreSQL, then i would try a GROUP BY expression:


if its directly in ArcGIS, then i would use summarize. This requires you have to already have a column with the area of each row, if its not possible to add columns. If thats the case, then right-click the "name" column's header -> summarize -> field: area, statistic type: max


I see no need for SQL to be involved in this because ArcMap with the Maplex Labeling Engine (included with all license levels) supports Labeling the largest feature part for polygons:

Sometimes a group of geographic features is represented by a single multipart polygon feature. For example, in a feature class of the United States, the state of Hawaii could be represented as one polygon with multiple parts. When labeling such features with the Maplex Label Engine, you can choose between labeling each part of the feature with the same label or placing one label for the largest part.


Here is a workaround using MS excel. Make two new fields in your polygon layer: label_yes (short integer) and OID2. Field calculate your existing OID field to OID2 (sometimes arcmap doesn't include OID when you export to excel). Export the attribute table to excel and then sort descending on city name and size (shape_area), go to the data tab in excel, remove duplicate city names, make a label yes/no field in your city polygon, join the excel table in arcmap on OID2 with original polygon layer making the polygon layer the inner join table, select all records where your outer join OID2 field is not null, field calculate inner table field "label_yes" with 1. Remove join and make a label definition query to label only the features where "label_yes" = 1.

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.