Many times in geospatial work, the user needs to know the projection of different files in which they are working with, which generally requires a manual inspection of each file. This is a time consuming process especially when there are many files contained within the project. If the file is not loaded and not used in a geodatabase then a manual inspection of the projection file is required using Windows Explorer. The following script will utilize a new command call SpatialReference. This command can be placed in a loop to determine the spatial reference of all files in a mapping project, in this case, only a single file is used; therefore, it is probably quicker to do this manually. The code if Figure 8 assumes the file is in a folder and not a geodatabase.
- The first line of the code in Figure 8 sets the pathway to a projection shapefile. The pathway will be different on the learner’s computer.
- The next functional line of code defines a new variable based on the SpatialReference operation.
- A new variable is created which will contain only the name of what was retrieved with the SpatialReference command. The reason this new variable was required is that the SpatialReference command returns more information than just the name.
- The final operation is to print the projection of the file.