Select to view content in your preferred language

Apply datum tranformation only if source datum is different than target

882
4
Jump to solution
10-22-2021 12:49 PM
ZacharyHart
Honored Contributor

I'm trying to create a simple evaluation within a script which does not restrict the spatial reference of the data, but the output is fixed: WGS 1983 Web Mercator Aux Sphere. All inputs will be projected data.

I want to project any input data to match the desired output projection, but I need to evaluate the datum of the input vs the output. .

Unfortunately, according to the documentation found here, this property (GCSName) is available only for geographic data. However:

Because a projected coordinate system is based on a geographic coordinate system, projected coordinate system properties can be accessed from a geographic coordinate system via the GCS property.

But the GCS property returns a spatial reference object for which I do not know how to format or parse parameters from to evaluate. Is there a way to do this? This will eventually be rolled-up into a script tool.

Any general tips on handling such a process would be greatly appreciated. I anticipate there will only be a handful of input PCS to deal with but it is entirely possible that there both NAD83 & WGS84 datums (3 feet matters for us in this case!).

 

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

for my example

sr.GCS
<geoprocessing spatial reference object at 0x243ed372af0>

sr.GCS.name
'GCS_North_American_1983'

instead of parsing the whole string


... sort of retired...

View solution in original post

4 Replies
DanPatterson
MVP Esteemed Contributor

 

in_fc = r"C:\Git_Dan\npgeom_bak\Project_npg\npgeom.gdb\Ontario_singlepart"
sr = arcpy.Describe(in_fc).spatialReference

sr.name
'NAD_1983_Statistics_Canada_Lambert'

sr.exportToString()
'PROJCS["NAD_1983_Statistics_Canada_Lambert",
        GEOGCS["GCS_North_American_1983",
        DATUM["D_North_American_1983",
        SPHEROID["GRS_1980",6378137.0,298.257222101]],
        PRIMEM["Greenwich",0.0],
        UNIT["Degree",0.0174532925199433]],
 PROJECTION["Lambert_Conformal_Conic"],
 PARAMETER["False_Easting",6200000.0],
 PARAMETER["False_Northing",3000000.0],
 PARAMETER["Central_Meridian",-91.86666666666666],
 PARAMETER["Standard_Parallel_1",49.0],
 PARAMETER["Standard_Parallel_2",77.0],
 PARAMETER["Latitude_Of_Origin",63.390675],
 UNIT["Meter",1.0]];-28455800 -28572600 10000;-100000 10000;-100000 
 10000;0.001;0.001;0.001;IsHighPrecision'

 

There are easier ways to get at the information, but every projected coordinate system has a root GCS and hence a datum associated with (lines 9 and 10).  You just have to sift through the properties

SpatialReference—ArcGIS Pro | Documentation


... sort of retired...
ZacharyHart
Honored Contributor

Thanks Dan! That's the same doc I linked to as well. I'm able to generate the string, but are the items in the Spatial Reference object indexed so I can parse them out? Are they keyed? The documentation isn't very detailed.

Thanks again, you do so much for us!

0 Kudos
DanPatterson
MVP Esteemed Contributor

for my example

sr.GCS
<geoprocessing spatial reference object at 0x243ed372af0>

sr.GCS.name
'GCS_North_American_1983'

instead of parsing the whole string


... sort of retired...
ZacharyHart
Honored Contributor

that works, thanks!! i'm off to the races now.

0 Kudos