Select to view content in your preferred language

Apply symbology, labels, hatches in arcpy

3413
6
11-06-2011 10:00 PM
RogerLoweth
Emerging Contributor
I have a polyline ZM layer into which I want to apply symbology, route/hatching and labels from an eixsting layer on disk.

I know how to do the symbology:
arcpy.ApplySymbologyFromLayer_management(out_layer, in_layer)

Does anyone know how to apply route/hatching and lables programmatically?

Cheers, Roger
Tags (2)
0 Kudos
6 Replies
JeffBarrette
Esri Regular Contributor
0 Kudos
RogerLoweth
Emerging Contributor
Thanks for the advice Jeff.

I'm trying UpdateLayer but it's not working yet - but (oddly enough) not throwing an exception either.

Will have another play today.

Roger
0 Kudos
RogerLoweth
Emerging Contributor
Is working now - finger trouble 😞

Many thanks Jeff 🙂
0 Kudos
deleted-user-MS0lE1F_0-sy
Deactivated User
Is there a way to do this with just the LABELS?  To my understanding with UpdateLayer is that it's just symbology or everything.  I just want to bring over just the symbology and labels and no other layer properties.
0 Kudos
JeffBarrette
Esri Regular Contributor
No there is not.  You would need to author the layer file with all the layer properties and then use it with UpdateLayer.  This doesn't make sense if you only want to update one or two layers but if you want to update the same layer multiple times in multiple MXDs it may be worthwhile.

Jeff
0 Kudos
deleted-user-MS0lE1F_0-sy
Deactivated User
FYI - In case someone comes across this same issue.

I authored the layer file as suggested.  However the UpdateLayer is limited on what it can do.  It can either get the symbology from another layer, or it basically Removes and Adds a new layer.  Instead this is what I ended up having to do.

# 1st make sure the authored layer is in the map.

for lyr in arcpy.mapping.ListLayers(mxd5):
    if lyr.supports("DATASOURCE"):
        if lyr.dataSource == r"C:\Location of the authored layer\the name of the authored layer":
            lyr.replaceDataSource(r"C:\Location of the new data","FILEGDB_WORKSPACE","name as it appears in the workspace")
            lyr.name = "name as it appears in the workspace"
0 Kudos