Batch Project (Data Management)
Summary
Changes the coordinate system of a set of input feature classes or feature datasets to a common coordinate system. To change the coordinate system of a single feature class or dataset use the Project tool.
Usage
-
Any valid inputs to the Project tool, such as all feature classes or feature datasets, are also valid inputs for this tool.
-
Although both the Output Coordinate System and Template Dataset are optional parameters, one of them must be entered. Keeping both of these parameters empty will cause tool execution to fail.
-
As the tool does not validate whether a transformation is required, use the Project tool first with one of the inputs to determine whether any transformation is required. The drop-down list of the Project tool's Geographic Transformation parameter shows which transformations (if any) are valid.
-
A feature class or dataset with an undefined or Unknown coordinate system must first have its coordinate system defined using the Define Projection tool before it can be used with the tool.
-
The names of the output feature classes will be based on the names of the input feature classes. For instance, if the input is C:\myworkspace\Gondor.shp, the output feature class will be named Gondor.shp. If the name already exists in the output workspace, a number will be appended (for example, _1) to the end to make it unique (Gondor_1.shp) in the output workspace.
Syntax
Parameter | Explanation | Data Type |
Input_Feature_Class_or_Dataset [Input_Feature_Class_or_Dataset,...] |
The input feature classes or feature datasets whose coordinates are to be converted. | Geodataset |
Output_Workspace |
The location of each new output feature class or feature dataset. | Feature Dataset; Workspace |
Output_Coordinate_System (Optional) |
The coordinate system to be used to project the inputs. Valid values are a Spatial Reference object, a file with a .prj extension, or a string representation of a coordinate system. | Coordinate System |
Template_dataset (Optional) |
The feature class or the feature dataset used to specify the output coordinate system used for projection. | Geodataset |
Transformation (Optional) |
Name of the geographic transformation to be applied to convert data between two geographic coordinate systems (datums). | String |
Code Sample
The following Python window script demonstrates how to use the BatchProject function in immediate mode.
import arcpy arcpy.env.workspace = "C:/data/input/batchproject" arcpy.BatchProject_management(["citylim.shp", "flood.shp", "faultzn.shp"], "C:/data/output/batchproject", "", "C:/data/usa.gdb/templatefc")
The following Python script demonstrate how to use the BatchProject function in a stand-alone script.
# Name: BatchProject.py # Description: Changes coordinate systems of several datasets in a batch. import arcpy from arcpy import env # Set workspace environment env.workspace = "C:/data/wgs1972.gdb" # Input feature classes input_features = ["cities", "counties", "blocks", "crime"] # Output workspace out_workspace = "C:/data/output.gdb" # Output coordinate system - leave it empty out_cs = '' # Template dataset - it has GCS_WGS_1984 coordinate system template = "C:/data/wgs1984.gdb/stateparks" # Geographic transformation - transformation = "WGS_1972_To_WGS_1984_1" try: res = arcpy.BatchProject(input_features, out_workspace, out_cs, template, transformation) if res.maxSeverity == 0: print "projection of all datasets successful" else: print "failed to project one or more datasets" except: print res.getMessages()