Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Using arcobjects, I am trying to programmatically create a composite geotransformation and then use to project features with the geoprocessor. Found old VB6 code out there on the web, but I can't get it to work in C# .NET. When I try to use the projection tool in the geoprocessor, it fails and sends back a message saying "Invalid geographic transformation." The code I am using is below. Either I have built the composite transformation incorrectly, or, the geoprocessor cannot find it. Any ideas?

EDIT UPDATE:

private void createAndUseCompositeGeoTrans()
    {
        Geoprocessor gp = new Geoprocessor();
        gp.OverwriteOutput = true;
        object sev = 2;
        object dt = "";

        try
        {
            ISpatialReferenceFactory2 spatialReferenceFactory2 = new SpatialReferenceEnvironmentClass();
            ISpatialReference in_spatialReference1 = 
                spatialReferenceFactory2.CreateSpatialReference(esriSRProjCSType.esriSRProjCS_NAD1983SPCS_WASouthFT.GetHashCode());

            ISpatialReference out_spatialReference2
               = spatialReferenceFactory2.CreateSpatialReference(esriSRProjCS2Type.esriSRProjCS_WGS1984SphereWebMercator.GetHashCode());
            ICompositeGeoTransformation compGeoTrs = (ICompositeGeoTransformation)new CompositeGeoTransformation();

            //NAD1983_To_WGS1984_1
            IGeoTransformation geoTransformation_A = spatialReferenceFactory2.CreateGeoTransformation((int)esriSRGeoTransformationType.esriSRGeoTransformation_NAD1983_To_WGS1984_1) as IGeoTransformation;
            compGeoTrs.Add(esriTransformDirection.esriTransformForward, geoTransformation_A);

            // WGS_1984_Major_Auxiliary_Sphere_To_WGS_1984
            IGeoTransformation geoTransformation_B = spatialReferenceFactory2.CreateGeoTransformation(108100) as IGeoTransformation;
            compGeoTrs.Add(esriTransformDirection.esriTransformReverse, geoTransformation_B);

            compGeoTrs.Name = "NAD1983_To_WGS_1984_Major_Auxiliary_Sphere";

            IMapGeographicTransformations mapGeotrans = (IMapGeographicTransformations)map;
            IGeoTransformationOperationSet geoTransOperationSet = mapGeotrans.GeographicTransformations;

            geoTransOperationSet.Set(esriTransformDirection.esriTransformForward, compGeoTrs);
            geoTransOperationSet.Set(esriTransformDirection.esriTransformReverse, compGeoTrs);
            ESRI.ArcGIS.Carto.IActiveView activeView = (ESRI.ArcGIS.Carto.IActiveView)map;
            activeView.Refresh();

            ESRI.ArcGIS.DataManagementTools.Project projectTool = new ESRI.ArcGIS.DataManagementTools.Project();
            projectTool.in_dataset = "C:\\projects\\clients\\Freeport\\CAD_Tool\\sampledata\\Point.shp";
            projectTool.out_dataset = "C:\\projects\\clients\\Freeport\\CAD_Tool\\sampledata\\Test_002.shp"; ;
            projectTool.in_coor_system = spatialReferenceFactory2.CreateProjectedCoordinateSystem(in_spatialReference1.FactoryCode);
            projectTool.out_coor_system = spatialReferenceFactory2.CreateProjectedCoordinateSystem(out_spatialReference2.FactoryCode);
            projectTool.transform_method = "NAD1983_To_WGS_1984_Major_Auxiliary_Sphere";
            gp.Execute(projectTool, null);


        }
        catch (System.Runtime.InteropServices.COMException CE)
        {
            //throw CE;
            printMsg(rTxtBx_console, CE.Message + "\n\nLast GP Message:\n" + gp.GetMessages(ref sev), MsgTypes.err);
        }
        catch (Exception E)
        {
            printMsg(rTxtBx_console, E.Message + "\n\nLast GP Message:\n" + gp.GetMessages(ref sev), MsgTypes.err);
        }

    }
share|improve this question
    
If you had a higher accept rate you might get more responses. –  Kirk Kuykendall Sep 19 '11 at 13:43
1  
Kirk, thank you for the reminder. I have been negligent. –  rgwozdz Sep 19 '11 at 14:48

1 Answer 1

up vote 1 down vote accepted

Currently you do not have a valid composite geographic (datum) transformation. The input GCS is NAD 1983 HARN, not NAD 1983. You either need to change GT A to handle NAD 1983 HARN - WGS 1984 or change A to cover NAD83 - NAD83 HARN and make the current two transformations B and C.

If you go for the second case, many NAD 1983 - NAD 1983 HARN transformations are file-based so you'll need the pedata folder from ArcGIS desktop.

Lists of supported transformations for various versions are here.

share|improve this answer
    
If I create a CompositeGeotransformation is there some way to save it into the pe data folder so that it can be found if I use it's name in the Project gp tool? –  Kirk Kuykendall Sep 19 '11 at 15:46
    
Thanks - you pointed out an important problem. In fact, I had the original input and output CS wrong - my sample shape file actually had an in CS of NAD1983SPCS_WASouthFT and my out CS should have been esriSRProjCS_WGS1984SphereWebMercator. I've edited the code above. However, I still have the "Invalid geographic transformation" error. It seems like the gp can't see the new composite geo transformation. –  rgwozdz Sep 19 '11 at 16:10
    
@KirkKuykendall, unfortunately, no. The method would be as a gtf file, but they weren't designed to support the composite transformation. Projection engine doesn't support a composite transformation as a separate 'object' so there's no back-door available. –  mkennedy Sep 19 '11 at 18:09
    
@rgwozdz, Do you have to use esriSRProjCS_WGS1984SphereWebMercator? This maps to 102113. If you're using 10, you could use 102100 aka 3857. This is based on WGS84, not WGS84 auxiliary sphere so you only need a single transformation. Another possibility to do the conversion in two processes. –  mkennedy Sep 19 '11 at 18:11
    
@mkennedy, Unfortunately esriSRProjCS_WGS1984SphereWebMercator is required. Yes, I am working on doing the conversion in multiple project processes now. A pain, but at least there is a work around. Thanks very much. –  rgwozdz Sep 19 '11 at 18:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.