Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose given a point (IPoint) in some coordinate system. Required to transform it to another coordinate system. If both of coordinate systems are predefined, we can use IGeometry2.ProjectEx with transformation specified by corresponded constant from esriSRGeoTransformationType, esriSRGeoTransformation2Type, or esriSRGeoTransformation3Type enumerations.

The code looks like (source)

package arcgissamples.geometry;

import com.esri.arcgis.geometry.*;
import com.esri.arcgis.system.*;

public class ProjectGeometry {

  public static void main(String[] args) {
    try {
      AoInitialize aoInit = new AoInitialize();

      // Create a point with Geographic coordinates...
      Point point = new Point();
      point.putCoords(-100.0, 40.0);

      System.out.println("Original coordinates: " + point.getX() + ","
                + point.getY());

      // Create the SpatialReferenceEnvironment...
      SpatialReferenceEnvironment spatialReferenceEnvironment = new SpatialReferenceEnvironment();

      // Apply the initial spatial reference...
      ISpatialReference geographicCoordinateSystem = spatialReferenceEnvironment

      // Create the output projected coordinate system...
      ISpatialReference projectedCoordinateSystem = spatialReferenceEnvironment

      // Create the GeoTransformation...
      // !!!! How to define arg for createGeoTransformation??
      IGeoTransformation iGeoTransformation = (IGeoTransformation) spatialReferenceEnvironment

      // Project the point...
      point.projectEx(projectedCoordinateSystem, esriTransformDirection.esriTransformForward,
                iGeoTransformation, false, 0.0, 0.0);
      System.out.println("Projected coordinates: " + point.getX() + " , "
                + point.getY());



    } catch (Exception ex) {

But problem is that both original coordinate system and output coordinate system are defining at the time of program execution. So I need a function to define constant for ISpatialReferenceFactory.CreateGeoTransformation method like

int defineTransformationType(ISpatialReference srcCoordSystem, ISpatialReference destCoordSys)

Is it possible? And how to implement this function?

share|improve this question
up vote 2 down vote accepted

Instead of creating a geotransformation, I would try finding one. This can be done by looping through all the predefined geotransformations via CreatePredefinedGeographicTransformations and checking to see if the input and output spatialreferenceID's match the GCS's of your spatialreferences. See code here.

share|improve this answer

Your Answer


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.