Save all layers in map to layer files

    Table of contents
    No headers

    Version as of 01:34, 15 Jan 2012

    to this version.

    Return to Version archive.

    View current version

    I'm in the final stretches of building Yukon Canvec and found myself in need of repeatedly saving multiple layers to disk. I got tired of click, click, click and decided to learn a bit more about using arcpy interactively. The result is a short immediate mode python snippet:

    import arcpy
    arcpy.env.workspace = r'r:\Layers'
    layers = ['Index','Toponomy','Places of Interest','Transportation','Energy','Industrial and Commercial','Buildings and Structures','Hydrography','Water Saturated Soils','Relief and Landforms','Vegetation']
    for lyr in layers:
        arcpy.SaveToLayerFile_management(lyr, lyr + '.lyr', "RELATIVE")

    It's pretty slow, but not as slow as doing it all by hand! Now all that's needed is a means to make "layer =" line populated automatically from the map instead of hard coded, and then this could be attached to a button.

        Send feedback