Select to view content in your preferred language

Labelling using python

278
2
Jump to solution
a month ago
HusamOqer
New Contributor II

Hello everyone!

I am working on python automation for a project and I need to show the labelling for one of the features on the map based on one of the fields.

I am not sure what functions is used usually to show the labeling.

Appreciate your support!

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
ChrisCowin_dhs
New Contributor III

 

import arcpy
import os

# Place in ArcGIS Project Folder
path = os.getcwd()
aprx = arcpy.mp.ArcGISProject(os.path.join(path, 'APRX_File_Name.aprx'))
for map in aprx.listMaps():
    print(' Map: ' + map.name)
    for lyr in map.listLayers():
        print('  Layer: ' + lyr.name)

        if lyr.name == 'The Layer Name whose Labels youd like to enable':
            lyr.showLabels = True

aprx.save()

 

 

Give this a shot

View solution in original post

2 Replies
ChrisCowin_dhs
New Contributor III

 

import arcpy
import os

# Place in ArcGIS Project Folder
path = os.getcwd()
aprx = arcpy.mp.ArcGISProject(os.path.join(path, 'APRX_File_Name.aprx'))
for map in aprx.listMaps():
    print(' Map: ' + map.name)
    for lyr in map.listLayers():
        print('  Layer: ' + lyr.name)

        if lyr.name == 'The Layer Name whose Labels youd like to enable':
            lyr.showLabels = True

aprx.save()

 

 

Give this a shot

HusamOqer
New Contributor II

It works thank you!
Now I can implement it and move on.

0 Kudos