Click or drag to resize

GeometryEngineProject Method (Geometry, SpatialReference, DatumTransformation)

Projects the given geometry from its current spatial reference system into the given output spatial reference system, applying the datum transformation provided.

Namespace:  Esri.ArcGISRuntime.Geometry
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.9.0
Syntax
public static Geometry Project(
	Geometry geometry,
	SpatialReference outputSpatialReference,
	DatumTransformation datumTransformation
)

Parameters

geometry
Type: Esri.ArcGISRuntime.GeometryGeometry
The geometry to be projected.
outputSpatialReference
Type: Esri.ArcGISRuntime.GeometrySpatialReference
The spatial reference to which geometry need to be projected.
datumTransformation
Type: Esri.ArcGISRuntime.GeometryDatumTransformation
The datum transformation that describes how coordinates are converted from one geographic coordinate system to another.

Return Value

Type: Geometry
The geometry projected into the given SpatialReference. If the input geometry has a null SpatialReference, no projection occurs; instead, an identical geometry with the given SpatialReference is returned.
Remarks
Use this overload to project a geometry if the difference between the input geometry's SpatialReference and the outputSpatialReference involves a change of datum, and you do not wish to use the default datum transformation used by Project(Geometry, SpatialReference). Using a HorizontalVerticalTransformation will also transform the z-values of the geometry (if the geometry has them) if both the SpatialReference of the geometry and the outputSpatialReference have a vertical coordinate system set.
Examples

WPF

Example Name: ProjectWithSpecificTransformation

Project a point from one coordinate system to another using a specific transformation step.

Code example screen shot.

C#
// Copyright 2018 Esri.
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
// language governing permissions and limitations under the License.

using Esri.ArcGISRuntime.Geometry;
using System;

namespace ArcGISRuntime.WPF.Samples.ProjectWithSpecificTransformation
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        name: "Project with specific transformation",
        category: "Geometry",
        description: "Project a point from one coordinate system to another using a specific transformation step.",
        instructions: "View the values for: unprojected point, projected with the GeometryEngine default, and projected with a specific transformation step.",
        tags: new[] { "coordinate system", "geographic", "project", "projection", "transform", "transformation", "transformation step" })]
    public partial class ProjectWithSpecificTransformation
    {
        public ProjectWithSpecificTransformation()
        {
            InitializeComponent();

            Initialize();
        }

        private void Initialize()
        {
            // Create a point geometry in NYC in WGS84
            MapPoint startingPoint = new MapPoint(-73.984513, 40.748469, SpatialReferences.Wgs84);

            // Update the UI with the initial coordinates
            BeforeLabel.Content = String.Format("x: {0}, y: {1}", startingPoint.X, startingPoint.Y);

            // Create a geographic transformation step for transform WKID 108055, WGS_1984_To_MSK_1942
            GeographicTransformationStep geoStep = new GeographicTransformationStep(108055);

            // Create the transformation
            GeographicTransformation geoTransform = new GeographicTransformation(geoStep);

            // Project to a coordinate system used in New York, NAD_1983_HARN_StatePlane_New_York_Central_FIPS_3102
            MapPoint afterPoint = (MapPoint)GeometryEngine.Project(startingPoint, SpatialReference.Create(2829), geoTransform);

            // Update the UI with the projected coordinates
            AfterLabel.Content = String.Format("x: {0}, y: {1}", afterPoint.X, afterPoint.Y);

            // Perform the same projection without specified transformation
            MapPoint unspecifiedTransformPoint = (MapPoint)GeometryEngine.Project(startingPoint, SpatialReference.Create(2829));

            // Update the UI with the projection done without specific transform for comparison purposes
            NonSpecificLabel.Content = String.Format("x: {0}, y: {1}", unspecifiedTransformPoint.X, unspecifiedTransformPoint.Y);
        }
    }
}
XAML
<UserControl x:Class="ArcGISRuntime.WPF.Samples.ProjectWithSpecificTransformation.ProjectWithSpecificTransformation"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <StackPanel>
        <Label Content="Geometry before (WGS 84):" />
        <Label x:Name="BeforeLabel" />
        <Label Content="Geometry to NAD_1983_HARN_StatePlane_New_York_Central_FIPS_3102 after WGS_1984_To_MSK_1942:" />
        <Label x:Name="AfterLabel" />
        <Label Content="Geometry to NAD_1983_HARN_StatePlane_New_York_Central_FIPS_3102 after (without specific transform)" />
        <Label x:Name="NonSpecificLabel" />
    </StackPanel>
</UserControl>
See Also
Additional Examples
Hyperlink to ExampleDescription
ListTransformationsGet a list of suitable transformations for projecting a geometry between two spatial references with different horizontal datums.
ProjectWithSpecificTransformationProject a point from one coordinate system to another using a specific transformation step.