0

I have a point feature class, in certain areas there are stacked points. These stacked points are accurate. However, when I label the points I am getting a label for each point, which is okay for each unique attribute that is being displayed. However, there are some points that have the same attribute information being displayed, where I would only like one label.

Example:

enter image description here

How can I display one label for all stacked points if their attribute information is the same? So that it would look like:

enter image description here

Any thougts? I am using a point feature class from ArcSDE 10.2.2.

I cannot alter that data in any way and I am required to used this dataset. Also, I will be publishing it as a dynamic mapping service and documentation has suggested that Maplex Label Engine is not recommend since it slows down performance.

I am looking for a work around taking account into these requirements.

4 Answers 4

5

Approach 1: Maplex Remove Duplicates

First, make sure you are using the Maplex Label Engine by checking the box in the Labeling toolbar. You can also set the Maplex Label Engine to be the default in Customize > ArcMap Options > Data View tab > Default Labeling Properties.

Maplex

Second, check the Remove duplicates box in the Label Density tab of the Placement Properties of the layer you are labeling. You can also customize the radius in which duplicates are searched.

Remove duplicates

Approach 2: Label classes

If you can't use Maplex (as you've noted) or you are labeling coincident points by a field with unique values for each feature, we need to take a different approach. First, add a new integer field called Label to your attribute table.

Second, in field calculator, flag duplicate records by running a special field calculator expression on your new field. Use the expression isDuplicate(!Shape!), assuming Shape is the name of your geometry field, the PYTHON_9.3 parser, and the following Python code in the optional code block. This will flag the first instance of each geometry with a 0, duplicates with a 1, and null or invalid geometry with a -1.

uniqueList = []
def isDuplicate(inputShape):
    if inputShape is None or inputShape.pointCount == 0 or inputShape.firstPoint is None:
        return -1
    else:
      hashableShape = (inputShape.firstPoint.X, inputShape.firstPoint.Y)
      if hashableShape in uniqueList:
        return 1
      else:
        uniqueList.append(hashableShape)
        return 0

Field calculator duplicate identification

Then, you can use label classes to only label features that have a 0 in the Label fieldvia a SQL query. This should remove duplicate labels.

Label classes

3
  • Thanks for the suggestion. I forgot to mention that I will be publishing this data as a dynamic mapping service and I have read that using Maplex Label Engine not recommended since it slows down performance. I am trying to find another workaround.
    – a1234
    Jun 2, 2015 at 19:46
  • @arzola I added an alternative/workaround solution that does not use Maplex.
    – dmahr
    Jun 2, 2015 at 20:11
  • @dmahr, great second suggestion. Elegant.
    – Fezter
    Jun 2, 2015 at 23:14
1

Al the sugggestions were great, but this is my quick work around that I just discovered.

  1. In Table on Contents, Right Click layer > Properties
  2. Labels Tab
  3. Placement Properties
  4. Change Point Setting to 'Offset label horizontally around the point' = 'Top Center'

enter image description here

Before:

enter image description here

After:

enter image description here

1

Create new text field, populate it by concatenation of x,y, label. Find duplicates , they are points not to label.

UPDATED ANSWER with no modification to table:

def FindLabel ( [FID], [LABEL] ):
  fMin=[FID]
  mxd = arcpy.mapping.MapDocument("CURRENT")
  lr=arcpy.mapping.ListLayers(mxd, "ends")[0]
  with arcpy.da.SearchCursor(lr, ('Shape@XY', "LABEL" ),r'"FID"='+str( [FID] )) as cursor:
      for row in cursor:
         aKey=row
  with arcpy.da.SearchCursor(lr, ('Shape@XY', "LABEL","FID" )) as cursor:
      for row in cursor:
         comp=row[:2]
         changes=filter(lambda x: x not in aKey, comp)
         if len(changes)==0:
            fMin=min(fMin,row[2])
  if int([FID])==int(fMin): 
     return aKey[1]
  else:
     return ""

tested on shapefile.

Before:

enter image description here

after

enter image description here

2
  • Thanks for the suggestions, I forgot to mention that I cannot alter the data in any way, and have to use this specific dataset. I have updated my question.
    – a1234
    Jun 2, 2015 at 19:49
  • My sol is a variation of FelixIP's...just in a separate table. Labeling is of course based on a join...probably slows things a little for the service, but I have something similar that seems to perform fine for a moderate number of records. Jun 2, 2015 at 20:13
0

This solution may be clunky but adequate based on your restrictions...requires some scripting, or at any rate, that's how I'd do it. You can label based on a joined table. You can set up a dummy table with a cloned unique identifier in the orig table. Then use a sorted updatecursor on the label values to only populate a dummy field (in the joined dummy table) for the first unique record value. Easy to do. That's the key, getting the joined dummy field filled correctly -- leave the dups empty. Then with the regular label engine you may conditionally label only the records with values populated...for any overlapping points with unique values, there will be a label. This is a sort of primitive LUT (look up table).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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