ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Core.Geometry Namespace / GeometryEngine Class / Transform2D Method
The set of coordinates to be transformed.
The projection transformation specifying the input and output spatial references and possibly the geographic transformations to use for the transformation.
The set of transformed coordinates. If it is null or the length is less than the length of inCoordinates, then a new array will be allocated.
(Optional) The boolean value specifying whether to remove clipped coordinates or not. If true, the coordinates outside of the horizon will be removed from the output, and the number of initialized elements in the output is the number of coordinates transformed which may be less than the number of elements in inCoordinates. If false, all coordinates are preserved, the clipped out coordinates are set to NaN in the output, and the number of elements in the output is equal to the number of elements in inCoordinates. The default value is true.
Example

In This Topic
    Transform2D Method (GeometryEngine)
    In This Topic
    Transforms an enumeration of 2D coordinates. Returns an enumeration of transformed 2D coordinates.
    Syntax

    Parameters

    inCoordinates
    The set of coordinates to be transformed.
    projectionTransformation
    The projection transformation specifying the input and output spatial references and possibly the geographic transformations to use for the transformation.
    outCoordinates
    The set of transformed coordinates. If it is null or the length is less than the length of inCoordinates, then a new array will be allocated.
    removeClippedCoordinates
    (Optional) The boolean value specifying whether to remove clipped coordinates or not. If true, the coordinates outside of the horizon will be removed from the output, and the number of initialized elements in the output is the number of coordinates transformed which may be less than the number of elements in inCoordinates. If false, all coordinates are preserved, the clipped out coordinates are set to NaN in the output, and the number of elements in the output is equal to the number of elements in inCoordinates. The default value is true.

    Return Value

    The number of transformed coordinates.
    Exceptions
    ExceptionDescription
    Input parameter, inCoordinates, is null.
    ProjectionTransformation is null.
    Remarks
    This method should be applied to batches of coordinates for fast projection.
    Example
    Transform2D
    // Not all of the input points are transformed as some of them are outside of the GCS horizon.
    Coordinate2D[] inCoords2D = new Coordinate2D[]
    {
      new Coordinate2D(-1, -1),
      new Coordinate2D(-2, -5),
      new Coordinate2D(-5, -11),
      new Coordinate2D(-10, -19),
      new Coordinate2D(-17, -29),
      new Coordinate2D(-26, -41),
      new Coordinate2D(-37, -5),
      new Coordinate2D(-50, -21),
      new Coordinate2D(-65, -39),
      new Coordinate2D(-82, -9)
    };
    
    int arraySize = inCoords2D.Length;
    
    ProjectionTransformation projTrans = ProjectionTransformation.Create(SpatialReferences.WGS84, SpatialReferenceBuilder.CreateSpatialReference(24891));
    
    Coordinate2D[] outCoords2D = new Coordinate2D[arraySize];
    
    // transform and choose to remove the clipped coordinates
    int numPointsTransformed = GeometryEngine.Instance.Transform2D(inCoords2D, projTrans, ref outCoords2D, true);
    
    // numPointsTransformed = 4
    // outCoords2D.Length = 4
    
    // outCoords2D[0] = {5580417.6876455201, 1328841.2376554986}
    // outCoords2D[1] = {3508774.290814558, -568027.23444226268}
    // outCoords2D[2] = {1568096.0886155984, -2343435.4394415971}
    // outCoords2D[3] = {57325.827391741652, 1095146.8917508761}
    
    // transform and don't remove the clipped coordinates
    numPointsTransformed = GeometryEngine.Instance.Transform2D(inCoords2D, projTrans, ref outCoords2D, false);
    
    // numPointsTransformed = 4
    // outCoords2D.Length = 10
    
    // outCoords2D[0] = {double.Nan, double.Nan}
    // outCoords2D[1] = {double.Nan, double.Nan}
    // outCoords2D[2] = {double.Nan, double.Nan}
    // outCoords2D[3] = {double.Nan, double.Nan}
    // outCoords2D[4] = {double.Nan, double.Nan}
    // outCoords2D[5] = {double.Nan, double.Nan}
    // outCoords2D[6] = {5580417.6876455201, 1328841.2376554986}
    // outCoords2D[7] = {3508774.290814558, -568027.23444226268}
    // outCoords2D[8] = {1568096.0886155984, -2343435.4394415971}
    // outCoords2D[9] = {57325.827391741652, 1095146.8917508761}
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also