ArcGIS Desktop

  • Documentation
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

Save To Layer File

  • Summary
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

Summary

Creates an output layer file (.lyr) from a map layer. The layer file stores many properties of the input layer such as symbology, labeling, and custom pop-ups.

Usage

  • In addition to map layers, this tool also accepts layers created by tools such as Make Feature Layer or Make XY Event Layer.

  • If the input layer has a selection applied to it, the output layer file will maintain this selection.

Syntax

SaveToLayerFile_management (in_layer, out_layer, {is_relative_path}, {version})
ParameterExplanationData Type
in_layer

The map layer to be saved to disk as a layer file.

Layer
out_layer

The output layer file (.lyr) to be created.

Layer File
is_relative_path
(Optional)

Determines if the output layer file will store a relative path to the source data stored on disk, or an absolute path.

  • ABSOLUTE —The output layer file will store an absolute path to the source data stored on disk. This is the default.
  • RELATIVE —The output layer file will store a relative path to the source data stored on disk. If the output layer file is moved, its source path will update to where the source data should be in relation to the new path.
Boolean
version
(Optional)

The version of the output layer file.

  • CURRENT —The current version. This is the default.
  • 10.4 —10.4
  • 10.3 —10.3
  • 10.2 —10.2
  • 10.1 —10.1
  • 10 —10
  • 9.3 —9.3
  • 9.2 —9.2
  • 9.1 —9.1
  • 9.0 —9.0
  • 8.3 —8.3
String

Code sample

SaveToLayerFile example 1 (Python window)

The following Python window script demonstrates how to use the SaveToLayerFile tool in immediate mode.

import arcpy
arcpy.env.workspace = "C:/data"
arcpy.SaveToLayerFile_management("studyquads.shp", "C:/output/studyquadsLyr.lyr", "ABSOLUTE")
SaveToLayerFile example 2 (stand-alone Python script)

The following Python script demonstrates how to use the SaveToLayerFile tool in a stand-alone script.

# Name: SaveToLayerFile_Example2.py
# Description: Saves an inMemory layer to a file on disk

# Import system modules
import arcpy

# Set workspace
arcpy.env.workspace = "C:/data"

# Set local variables
in_features = "study_quads.shp"
where_clause = '"NAME" = \'LA MESA\''
in_layer = "studyquadsLyr"
out_layer_file = "studyquadsLyr.lyr"

# Execute MakeFeatureLayer
arcpy.MakeFeatureLayer_management(in_features, "study_quads_lyr", where_clause)

# Execute SaveToLayerFile
arcpy.SaveToLayerFile_management("study_quads_lyr", out_layer_file, "ABSOLUTE")

Environments

  • Current Workspace
  • Scratch Workspace

Licensing information

  • ArcGIS Desktop Basic: Yes
  • ArcGIS Desktop Standard: Yes
  • ArcGIS Desktop Advanced: Yes

Related topics

  • An overview of the Layers and Table Views toolset
  • Using layers and table views
  • Working with layers and table views

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2017 Esri. | Privacy | Legal