1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] using python to update data source but keep symbology in Arc Pro

Discussão em 'Python' iniciado por Stack, Setembro 28, 2024 às 13:42.

  1. Stack

    Stack Membro Participativo

    I would like to update the data source of a few layers in a GDB regularly but keep the symbology. The symbology itself is done with unique symbols and Arcade. The Arcade is using a field that is created from a Join from a separate table.

    This is what I am attempting so far:

    project = arcpy.mp.ArcGISProject('CURRENT')
    m = project.listMaps('Map')[0]
    m.addDataFromPath(r'\\Lines.gdb\LINE')

    #Join
    arcpy.management.AddJoin(
    in_layer_or_view="LINE",
    in_field="LINE_TYPE_CODE",
    join_table="LINE_TYPE_CODE",
    join_field="LINE_TYPE_CODE",
    join_type="KEEP_ALL",
    index_join_fields="NO_INDEX_JOIN_FIELDS",
    rebuild_index="NO_REBUILD_INDEX"
    )

    #rename line
    for lyr in m.listLayers():
    if "LINE" in lyr.name:
    layername = str(lyr.name)
    lyr.name = lyr.name.replace(layername, "LINE_rename")

    #copy symbology
    arcpy.management.ApplySymbologyFromLayer(
    in_layer="LINE_rename",
    in_symbology_layer="Line_with_symbology)",
    symbology_fields=None,
    update_symbology="UPDATE"
    )


    At this point I'm just testing if this could even work so I manually 'fix' the arcade script, but nothing will symbolize - so I haven't tried to script that yet. There is also a definition query I'll have to deal with at some point or another.

    Right now, I'm hoping someone has some experience with this and can point out a much simpler method.

    Continue reading...

Compartilhe esta Página