How to get the geographic transformation programatically

428
1
01-10-2014 09:46 AM
LynneBridgford
New Contributor
I need to project a dataset to a different spatial reference.  The input and output spatial references have different datums so I need a geographic transformation. 

If I use the out of the box GP tool it gives me a list and a default.  You can also look at the ArcMap data frame properties and see the default.  At 10.1 the transformations presented in the drop-down list on the data frame properties are sorted by suitability for the layer's extent.

I have also found a python method do to this called ListTransformations.  The problem with this is that I'm using C# so it I cannot call a python method directly (at least not that I know of).

Does anybody know the best way to get the ESRI recommended default transformation using C#?
0 Kudos
1 Reply
JosephArmbruster
New Contributor III
You can use the SpatialReferenceEnvironmentClass.  Cast it to an ISpatialReferenceFactory and use the "CreateGeographicCoordinateSystem" method.  For ex:

ISpatialReferenceFactory spatial_reference_factory = new SpatialReferenceEnvironmentClass();
int wgs_84 = (int)esriSRGeoCSType.esriSRGeoCS_WGS1984;
IGeographicCoordinateSystem geo = spatial_reference_factory.CreateGeographicCoordinateSystem(wgs_84);
ISpatialReference spatial_reference = geo as ISpatialReference;

// you can set your spatial reference domain / etc... here if you'd like
spatial_reference.SetDomain(-180, 180, -90, 90);

Then you can use this spatial reference when you call Project.
0 Kudos