Define Projection (Data Management)

Summary

Overwrites the coordinate system information (map projection and datum) stored with a dataset. This tool is intended for datasets that have an unknown or incorrect coordinate system defined.

Usage

  • All geographic datasets have a coordinate system that is used throughout ArcGIS to display, measure, and transform geographic data. If the coordinate system for a dataset is unknown or incorrect, you can use this tool to specify the correct coordinate system.

  • This tool only updates the existing coordinate system information; it does not modify any geometry. To transform the geometry to another coordinate system, use the Project tool.

  • When a dataset with a known coordinate system is input to this tool, the tool will issue a warning message but will run successfully.

  • All feature classes in a geodatabase feature dataset are in the same coordinate system. The coordinate system for a feature dataset should be determined when it is created. Once a feature dataset contains feature classes, its coordinate system cannot be changed.

  • The tool will update the associated .wld file of a CAD or BIM file to retain the data's geographic adjusted position.

Parameters

LabelExplanationData Type
Input Dataset or Feature Class

The dataset or feature class whose projection will be defined.

Feature Layer;Geodataset
Coordinate System

The coordinate system that will be applied to the input.

Coordinate System

Derived Output

LabelExplanationData Type
Update Input Dataset or Feature Class

The updated input geodataset.

Geodataset

arcpy.management.DefineProjection(in_dataset, coor_system)
NameExplanationData Type
in_dataset

The dataset or feature class whose projection will be defined.

Feature Layer;Geodataset
coor_system

The coordinate system that will be applied to the input.

Valid values are a SpatialReference object, a file with a .prj extension, or a string representation of a coordinate system.

Coordinate System

Derived Output

NameExplanationData Type
out_dataset

The updated input geodataset.

Geodataset

Code sample

DefineProjection example (Python window)

The following Python Window script demonstrates how to use the DefineProjection function in immediate mode.

import arcpy
infc = r"C:\data\citylim_unk.shp"
sr = arcpy.SpatialReference("NAD 1983 UTM Zone 11N")
arcpy.DefineProjection_management(infc, sr)
DefineProjection example (stand-alone script)

The following stand-alone script uses the DefineProjection function to record coordinate system information for the input dataset.

# Name: DefineProjection.py 
# Description: Records the coordinate system information for the specified input dataset or feature class

# import system modules
import arcpy

# set workspace environment
arcpy.env.workspace = "C:/data"

try:
    # set local variables
    in_dataset = "citylim_unk.shp" #"forest.shp"
    
    # get the coordinate system by describing a feature class
    dsc = arcpy.Describe("citylim_utm11.shp")
    coord_sys = dsc.spatialReference
    
    # run the tool
    arcpy.DefineProjection_management(in_dataset, coord_sys)
    
    # print messages when the tool runs successfully
    print(arcpy.GetMessages(0))
    
except arcpy.ExecuteError:
    print(arcpy.GetMessages(2))
    
except Exception as ex:
    print(ex.args[0])

Related topics