Print

Print


NEARC-L,

I'm working on an arcpy-based tool in which I need to determine if the spatial references for two feature classes are the same, and I'd like your advice on the best way to do that.

In my research so far, I've learned:


*         Comparing different instances of identically-defined SpatialReference objects with the Python == operator yields False.


*         Folks online report doing things like compare the factoryCode or name properties. As far as I can tell, however, those properties are really only metadata whose values don't affect the functional definition of the coordinate system. So, two spatial references could be effectively the same, but with a different factoryCode or name value (see next).



*         For a more detailed comparison, I tried using the SpatialReference.exportToString()values. But, I can construct a case where the name is different, yet the functional properties of the coordinate systems are the same. For example, I can define my own coordinate system that is identical to a well-known one, but their string definitions will be different because of the names (as well as the factoryCode, PCSCode, etc.). The following two strings are identical except for their names (highlighted) and, of course, return False when compared:



o   Well-known: PROJCS['WGS_1984_Web_Mercator_Auxiliary_Sphere',GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Mercator_Auxiliary_Sphere'],PARAMETER['False_Easting',0.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',0.0],PARAMETER['Standard_Parallel_1',0.0],PARAMETER['Auxiliary_Sphere_Type',0.0],UNIT['Meter',1.0]];-20037700 -30241100 10000;-100000 10000;-100000 10000;0.001;0.001;0.001;IsHighPrecision


o   Custom: PROJCS['My_Custom_Name',GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Mercator_Auxiliary_Sphere'],PARAMETER['False_Easting',0.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',0.0],PARAMETER['Standard_Parallel_1',0.0],PARAMETER['Auxiliary_Sphere_Type',0.0],UNIT['Meter',1.0]];-20037700 -30241100 10000;-100000 10000;-100000 10000;0.001;0.001;0.001;IsHighPrecision

Therefore, my question is:


*         QUESTION: Is there any way to compare (in Python/arcpy) if two spatial references are functionally equivalent without doing a property-by-property comparison of their geographic, projected, and geodatabase coordinate system properties?

Thank you, in advance, for sharing your thoughts.

-Michael


Michael Mannion
Database Consultant | Mannion Geosystems | +1 617.939.9958 | http://www.manniongeo.com<http://www.manniongeo.com/>


------------------------------------------------------------------------- This list (NEARC-L) is an unmoderated discussion list for all NEARC Users.

If you no longer wish to receive e-mail from this list, you can remove yourself by going to http://s.uconn.edu/nearcsubscribe.