Select to view content in your preferred language

Label placement over other features and labels in ArcGIS Pro

1243
2
03-17-2021 06:02 AM
anyry
by
Occasional Contributor

I need place labels regardless of collisions with other layers. I use ArcPy and CIM. I need to place the label in the center of the polygon. At the same time, I need it not to change its position or disappear if it collides with another labels or feature. I try this code, but some labels are placed outside the polygons.

show_labels = m.listLayers("polygon23*")[0]
show_labels.showLabels = True

for lyr in m.listLayers("polygon23*"):
        if lyr.supports("SHOWLABELS"):
            if lyr.showLabels:
                for lblClass in lyr.listLabelClasses():
                    lblClass.expression = ''' "<FNT size='6'>" + $feature.label + "</FNT>"'''
                    
                    
label_show = m.listLayers('polygon23*')[0]
l_cim = label_show.getDefinition('V2')
lc = l_cim.labelClasses[0]

lc.maplexLabelPlacementProperties.polygonPlacementMethod = 'StraightInPolygon'
lc.maplexLabelPlacementProperties.placeOnlyInsidePolygon = True
lc.CIMStandardLabelPlacementProperties = 'allowOverlappingLabels'
0 Kudos
2 Replies
jcarlson
MVP Esteemed Contributor

One thing to watch out for: the default value for canOverrunFeature tends to be 80 points, which can allow labels to be placed outside of the polygon, even when you've turned on the setting that would apparently disallow this.

jcarlson_0-1615988600449.png

I would also suggest setting enablePolygonFixedPosition to "True", then set the internal zone priorities such that center is the only non-zero option, thus forcing your labels to render at the center of the polygon, no matter what.

- Josh Carlson
Kendall County GIS
0 Kudos
anyry
by
Occasional Contributor

Thanks, but it still doesn't work properly. I need the label stay inside the polygon, even if the polygon overlaps with another polygon. 

0 Kudos