Project with specific transformation

View inWPFUWPFormsiOSAndroid
View on GitHub

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

Image of project with specific transformation

Use case

While the geometry engine supports automatic transformation of geometry between coordinate systems, some coordinate system pairs have specific transformations defined for additional accuracy within certain areas. For example, your organization could work in a local state plane using the NAD83 or NAD83 (HARN) datums while collecting data in the standard WGS 1984 datum. Your organization can define a specific transformation step to use to ensure precise, reliable data collection.

How to use the sample

View the values for: unprojected point, projected with the GeometryEngine default, and projected with a specific transformation step.

How it works

  1. Get a locations coordinates in WGS 84.
  2. Use the geometry engine to project the point without specifying a transformation step. Display the result for comparison.
  3. Use the geometry engine to project the point, this time specifying a transformation step. Display the result.
  4. Compare the results to see how a specific transformation step can result in a slightly different (and potentially more accurate) result.

Relevant API

  • GeographicTransformation
  • GeographicTransformationStep

About the data

To avoid the need to project from mercator coordinates to WGS 84, this sample uses World Basemaps (WGS84) from ArcGIS Online's living atlas.

Additional information

See Spatial references in the ArcGIS Runtime SDK for .NET guide for more information about geographic coordinate systems, geographic transformations, and projected coordinate systems.

Tags

coordinate system, geographic, project, projection, transform, transformation, transformation step

Sample Code

ProjectWithSpecificTransformation.cs
                                                                                                                          
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// 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 Android.App;
using Android.OS;
using Android.Widget;
using Esri.ArcGISRuntime.Geometry;

namespace ArcGISRuntime.Samples.ProjectWithSpecificTransformation
{
    [Activity (ConfigurationChanges=Android.Content.PM.ConfigChanges.Orientation | Android.Content.PM.ConfigChanges.ScreenSize)]
    [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 class ProjectWithSpecificTransformation : Activity
    {
        // Label for showing the coordinates before projection
        private TextView _beforeLabel;

        // Label for showing the coordinates after projection with specific transformation
        private TextView _afterLabel;

        // Label for showing the coordinates after projection without specific transformation
        private TextView _nonSpecificLabel;

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            Title = "Project with specific transformation";

            // Create the UI, setup the control references and execute initialization
            CreateLayout();
            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.Text = $"x: {startingPoint.X}, y: {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.Text = $"x: {afterPoint.X}, y: {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.Text = $"x: {unspecifiedTransformPoint.X}, y: {unspecifiedTransformPoint.Y}";
        }

        private void CreateLayout()
        {
            // Create a new vertical layout for the app
            LinearLayout layout = new LinearLayout(this) { Orientation = Orientation.Vertical };
            layout.SetPadding(10, 10, 10, 10);

            // Create the labels
            _beforeLabel = new TextView(this);
            _afterLabel = new TextView(this);
            _nonSpecificLabel = new TextView(this);

            // Create three more labels to label the output
            TextView beforeLabelTitle = new TextView(this)
            {
                Text = "Geometry before (WGS 84):"
            };
            TextView afterLabelTitle = new TextView(this)
            {
                Text = "\nGeometry to NAD_1983_HARN_StatePlane_New_York_Central_FIPS_3102 after WGS_1984_To_MSK_1942:"
            };
            TextView nonSpecificLabelTitle = new TextView(this)
            {
                Text = "\nGeometry to NAD_1983_HARN_StatePlane_New_York_Central_FIPS_3102 after (without specific transform):"
            };

            // Set layout background color.
            layout.SetBackgroundColor(Android.Graphics.Color.White);

            // Set the text color for all of the labels.
            beforeLabelTitle.SetTextColor(Android.Graphics.Color.Black);
            afterLabelTitle.SetTextColor(Android.Graphics.Color.Black);
            nonSpecificLabelTitle.SetTextColor(Android.Graphics.Color.Black);

            _beforeLabel.SetTextColor(Android.Graphics.Color.Black);
            _afterLabel.SetTextColor(Android.Graphics.Color.Black);
            _nonSpecificLabel.SetTextColor(Android.Graphics.Color.Black);

            // Add all labels to the layout
            layout.AddView(beforeLabelTitle);
            layout.AddView(_beforeLabel);
            layout.AddView(afterLabelTitle);
            layout.AddView(_afterLabel);
            layout.AddView(nonSpecificLabelTitle);
            layout.AddView(_nonSpecificLabel);

            // Show the layout in the app
            SetContentView(layout);
        }
    }
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.