ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

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
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Save To Layer File

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

Summary

Creates an output layer file (.lyr) that references geographic data stored on disk.

Usage

  • This tool is used to save an in-memory layer, a layer file stored on disk, or a feature layer in ArcMap to a layer file (.lyr) that references geographic data stored on disk.

  • This tool accepts as input feature 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 in-memory layer, layer file stored on disk, or feature layer in ArcMap to be saved to disk as a layer file (.lyr).

Layer
out_layer

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

Layer File
is_relative_path
(Optional)

Determines if the output layer file (.lyr) 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 layer file the output will be saved as. The default is CURRENT.

  • CURRENT
  • 10.1
  • 10
  • 9.3
  • 9.2
  • 9.1
  • 9.0
  • 8.3
String

Code sample

SaveToLayerFile Example (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("studyquadsLyr", "C:/output/studyquadsLyr.lyr", "ABSOLUTE")
SaveToLayerFile Example (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_layer = "studyquadsLyr"
out_layer = "studyquadsLyr.lyr"

# MakeFeatureLayer variables
in_features = "study_quads.shp"
out_layer0 = "studyquadsLyr"
where_clause = '"NAME" = \'LA MESA\''
workspace = "C:/output"

# Execute MakeFeatureLayer
arcpy.MakeFeatureLayer_management(in_features, out_layer0, where_clause, workspace)

# Execute SaveToLayerFile
arcpy.SaveToLayerFile_management(in_layer, out_layer, "ABSOLUTE")

Environments

  • Current Workspace
  • Scratch Workspace

Licensing information

  • ArcGIS for Desktop Basic: Yes
  • ArcGIS for Desktop Standard: Yes
  • ArcGIS for 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 for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • 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 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal