I would like to be able to quickly scan a list of shapefiles and identify the coordinate system used by each file. In my mind's eye, this would look something like the Windows Explorer "details" view, showing in columnar format the properties of all the shapefiles in a given folder, including the coordinate system. I've hunted around but haven't found anything. Any help? Thanks.
Solved! Go to Solution.
Depending upon how you have indexing setup with ArcGIS Desktop, and how metadata is populated with your datasets, ArcCatalog does have an option to display projected and geographic coordinate systems of spatial datasets.
It has a somewhat Windows Explorer "details" look to it in the Contents tab of ArcCatalog.
The above example is for feature classes in a personal geodatabase, but it can work with shapefiles as well. I emphasize can because both indexing and metadata need to be in order for it all to work. Personally, it is a bit too fragile for me to rely on, but I wanted to throw it out for discussion purposes since it is built-in functionality.
My guess is that Esri went with displaying coordinate systems in ArcCatalog through metadata because it is much quicker to look up information from metadata than it is to extract information from the data itself, like coordinate systems.
If you are comfortable with Python and the Command Prompt, a fairly simple script could be written to output coordinate system information in a "dir" like format. The functional part of the code could look something like:
>>> import os >>> width = 24 >>> levels = 0 >>> >>> workspace = r'D:\geodata' >>> levels = len(workspace.split(os.path.sep)) + levels >>> >>> walk = arcpy.da.Walk(workspace, datatype="FeatureClass") >>> for dirpath, dirnames, filenames in walk: ... if len(dirpath.split(os.path.sep)) >= levels: ... del dirnames[:] ... ... print " Workspace of {}\n".format(dirpath) ... for f in filenames: ... desc = arcpy.Describe(os.path.join(dirpath, f)) ... SR = desc.spatialReference ... GCSName = SR.GCSName[:width-3] + (SR.GCSName[width-3:] and '.. ') ... PCSName = SR.PCSName[:width-3] + (SR.PCSName[width-3:] and '.. ') ... print "{: <{width}}{: <{width}}{}".format(GCSName, PCSName, f, width=width) ... print "" ... Workspace of D:\geodata GCS_North_American_19.. canadwshed_p.shp GCS_North_American_19.. canadwshed_p_dissolve.shp GCS_North_American_19.. plots.shp GCS_North_American_19.. plots_44.shp NAD_1983_UTM_Zone_15N plots_44_Project.shp >>>
Since arcpy.da.Walk doesn't include a parameter for limiting the recursion depth, I added some code to implement that functionality. The levels variable specifies the depth of subdirectories (including feature datasets) to walk. The width variable specifies how wide the columns are for displaying coordinate system information.
The empty values in some columns are not caused by my code, per se, but how the spatial reference object handles coordinate systems. If a dataset is projected, the spatial reference object only shows the projected coordinate system and not the associated geographic coordinate system. If the dataset is geographic, then it makes sense to leave the projected information blank.
Some people are giving this good reviews ... X-ray for arccatalog
http://www.arcgis.com/home/item.html?id=9ea218ff575f4a5195e01a2cae03a0ae
Thanks for the suggestion, Dan. It isn't obvious to me how the tool gets me what I want, but then I haven't yet explored it much. I do see that it consistently uses only "geodatabase" terminology, so I think it may not work at all with shapefiles.
Depending upon how you have indexing setup with ArcGIS Desktop, and how metadata is populated with your datasets, ArcCatalog does have an option to display projected and geographic coordinate systems of spatial datasets.
It has a somewhat Windows Explorer "details" look to it in the Contents tab of ArcCatalog.
The above example is for feature classes in a personal geodatabase, but it can work with shapefiles as well. I emphasize can because both indexing and metadata need to be in order for it all to work. Personally, it is a bit too fragile for me to rely on, but I wanted to throw it out for discussion purposes since it is built-in functionality.
My guess is that Esri went with displaying coordinate systems in ArcCatalog through metadata because it is much quicker to look up information from metadata than it is to extract information from the data itself, like coordinate systems.
If you are comfortable with Python and the Command Prompt, a fairly simple script could be written to output coordinate system information in a "dir" like format. The functional part of the code could look something like:
>>> import os >>> width = 24 >>> levels = 0 >>> >>> workspace = r'D:\geodata' >>> levels = len(workspace.split(os.path.sep)) + levels >>> >>> walk = arcpy.da.Walk(workspace, datatype="FeatureClass") >>> for dirpath, dirnames, filenames in walk: ... if len(dirpath.split(os.path.sep)) >= levels: ... del dirnames[:] ... ... print " Workspace of {}\n".format(dirpath) ... for f in filenames: ... desc = arcpy.Describe(os.path.join(dirpath, f)) ... SR = desc.spatialReference ... GCSName = SR.GCSName[:width-3] + (SR.GCSName[width-3:] and '.. ') ... PCSName = SR.PCSName[:width-3] + (SR.PCSName[width-3:] and '.. ') ... print "{: <{width}}{: <{width}}{}".format(GCSName, PCSName, f, width=width) ... print "" ... Workspace of D:\geodata GCS_North_American_19.. canadwshed_p.shp GCS_North_American_19.. canadwshed_p_dissolve.shp GCS_North_American_19.. plots.shp GCS_North_American_19.. plots_44.shp NAD_1983_UTM_Zone_15N plots_44_Project.shp >>>
Since arcpy.da.Walk doesn't include a parameter for limiting the recursion depth, I added some code to implement that functionality. The levels variable specifies the depth of subdirectories (including feature datasets) to walk. The width variable specifies how wide the columns are for displaying coordinate system information.
The empty values in some columns are not caused by my code, per se, but how the spatial reference object handles coordinate systems. If a dataset is projected, the spatial reference object only shows the projected coordinate system and not the associated geographic coordinate system. If the dataset is geographic, then it makes sense to leave the projected information blank.
Joshua,
Thanks very much for this. The ArcCatalog Options solution would be perfect if only most of my shapefiles had the appropriate metadata. They don't. I'm a complete newbie as far as Python scripting goes, but I will give your script a shot and see what I come up with.
To responded Dan Patterson's answer, here is the video that might help you understand it.