How To: Define projection for all files in a workspace
The instructions provided describe how to define the projection for all files in a workspace.
In ArcMap, use model iteration to define the projection for all files in a workspace. The Define Projection tool is used when the files have no projection assigned.
Ensure the option 'When connecting elements, display valid parameters when more than one is available' in the Geoprocessing Option dialog box is checked. The ModelBuilder Connect tool presents the option to select the target parameters.
- Create a new model.a. Navigate through the Catalog tree to a folder where a new toolbox can be created. Right-click the folder > New > Toolbox.
b. Rename the toolbox as desired.
c. Right-click the toolbox > New > Model. This creates a model in the toolbox and opens ModelBuilder for editing the model.
d. In the toolbox, right-click the model and select Rename to give it a name appropriate to its intended task.
Users may also view model properties by right-clicking the model > Properties > General tab. Here, users can type a name, label, and description for the model.
- Add an iterator to the model.a. If the new model is not already open, right-click the model and select Edit to open the model window.
b. In the model's main menu, click Insert > Iterators > Feature Classes. The iterator is white since no parameter values have been provided.
c. Double-click the Iterate Feature Classes hexagon and set the following tool parameter.• Workspace or Feature Dataset: An input workspace where all feature classes to be modified are stored. Examples of workspaces are a folder, geodatabase, or feature dataset.
Two additional parameters, 'Wildcard' and 'Feature Type', are used to restrict the feature classes chosen for iteration. This iterator has two output variables: the output feature class file, and the name of the output feature class. The output feature class file can be connected to the next tool in the model for processing, and the Name variable can be used for inline variable substitution.
d. Click OK after valid inputs are set in the Iterate Feature Class dialog box. A dark blue input is displayed.
ModelBuilder uses color to indicate the status of tools and variables. A white shape indicates input parameters have not been specified. Once entered, the iterator color changes to orange (other tools change to gold); inputs are displayed in blue and outputs in green.
The iterator before and after parameter values have been provided.
- Add the Define Projection tool to the model.a. Go to ArcToolbox > Data Management Tools > Projections and Transformations.
b. Drag and drop the Define Projection tool onto the ModelBuilder canvas in an empty area.
- In the model, use the Connect tool in the toolbar to connect the iterator’s output Feature Class variable to the Define Projection tool, and select 'Input Dataset or Feature Class.'
- In the model, double-click the Define Projection tool, and set the following tool parameters.• Input Dataset or Feature Class: A dataset or feature class whose projection is to be defined. If there are feature classes in the previously chosen workspace, this field is populated automatically with one of the feature classes. If the workspace is empty, this field shows a generic name as output.
• Coordinate System: The coordinate system to be applied to the input.
The Define Projection tool is used to define the projection of a feature class that does not have any coordinate system set. When the tool is run from the model, it does not create a new feature class as output; it only sets the projection for the original feature class. If the tool is used on a feature class that already has a projection defined, the following error message is returned: "000132: The dataset already has a projection defined."
- Set the following model parameters.a. Right-click the dark blue input to the iterator, and check the Model Parameter option. This exposes the parameter when the model is run from its toolbox.
b. Right-click the Define Projection tool, and select Make Variable > From Parameter > Coordinate System.
c. Right-click the Coordinate System oval, and check the Model Parameter option.
- Validate the model to check for any errors. Go to the model menu > Validate Entire Model.
A process in the model is ready to run only when all required parameters are provided for the iterator and the tool. In the model window, ensure all boxes and ovals are filled with color before running the model.
- Save the model, and go to Model > Model Properties > Parameters. View the parameter properties and change the names and order of parameters as desired.
To summarize what has been accomplished: The Iterate Feature Classes tool iterates over feature classes in a workspace. The output of the iterator is given to the Define Projection tool. The Define Projection tool modifies the input feature class rather than creating a new output feature class. When the model is run, the projection of the feature classes in the workspace is set by the tool.
- Run the model from its toolbox in ArcCatalog or the Catalog window in ArcMap.
- ArcGIS Help: Iterate Feature Classes (ModelBuilder)
- ArcGIS Help: Examples of using iterators in ModelBuilder
- ArcGIS Help: A quick tour of using iterators
- ArcGIS Help: An overview of the Iterator toolset