List transformations by suitability

View inAndroidFormsUWPWPFWinUIiOSView on GitHub

Get a list of suitable transformations for projecting a geometry between two spatial references with different horizontal datums.

Image of list transformations by suitability

Use case

Transformations (sometimes known as datum or geographic transformations) are used when projecting data from one spatial reference to another when there is a difference in the underlying datum of the spatial references. Transformations can be mathematically defined by specific equations (equation-based transformations), or may rely on external supporting files (grid-based transformations). Choosing the most appropriate transformation for a situation can ensure the best possible accuracy for this operation. Some users familiar with transformations may wish to control which transformation is used in an operation.

How to use the sample

Select a transformation from the list to see the result of projecting the point from EPSG:27700 to EPSG:3857 using that transformation. The result is shown as a red cross; you can visually compare the original blue point with the projected red cross.

Select 'Consider current extent' to limit the transformations that are appropriate for the current extent.

If the selected transformation is not usable (has missing grid files) then an error is displayed.

How it works

  1. Pass the input and output spatial references to TransformationCatalog.GetTransformationsBySuitability for transformations based on the map's spatial reference OR additionally provide an extent argument to only return transformations suitable to the extent. This returns a list of ranked transformations.
  2. Use one of the DatumTransformation objects returned to project the input geometry to the output spatial reference.

Relevant API

  • DatumTransformation
  • GeographicTransformation
  • GeographicTransformationStep
  • GeometryEngine
  • GeometryEngine.Project
  • TransformationCatalog

Additional information

Some transformations aren't available until transformation data is provided.

This sample uses a GeographicTransformation, which extends the DatumTransformation class. As of 100.9, ArcGIS Runtime also includes a HorizontalVerticalTransformation, which also extends DatumTransformation. The HorizontalVerticalTransformation class is used to transform coordinates of z-aware geometries between spatial references that have different geographic and/or vertical coordinate systems.

This sample can be used with or without provisioning projection engine data to your device. If you do not provision data, a limited number of transformations will be available.

To download projection engine data to your device:

  1. Log in to the ArcGIS for Developers site using your Developer account.
  2. In the Dashboard page, click 'Download APIs and SDKs'.
  3. Click the download button next to Projection Engine Data to download projection engine data to your computer.
  4. Unzip the downloaded data on your computer.
  5. Create an ~/ArcGIS/Runtime/Data/PEDataRuntime directory on your device and copy the files to this directory.

About the data

The map starts out zoomed into the grounds of the Royal Observatory, Greenwich. The initial point is in the British National Grid spatial reference, which was created by the United Kingdom Ordnance Survey. The spatial reference after projection is in web mercator.

Tags

datum, geodesy, projection, spatial reference, transformation

Sample Code

ListTransformations.xamlListTransformations.xamlListTransformations.xaml.cs
Use dark colors for code blocksCopy
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
<UserControl
    x:Class="ArcGISRuntime.UWP.Samples.ListTransformations.ListTransformations"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls"
    xmlns:local="using:ArcGISRuntime.UWP.Samples.ListTransformations"
    x:Name="_this">
    <Grid DataContext="{Binding ElementName=_this}">
        <esriUI:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <TextBlock
                    x:Name="InSpatialRefTextBox"
                    Grid.Row="0"
                    Grid.Column="0"
                    FontWeight="SemiBold" />
                <TextBlock
                    x:Name="OutSpatialRefTextBox"
                    Grid.Row="0"
                    Grid.Column="1"
                    HorizontalAlignment="Right"
                    FontWeight="SemiBold" />
                <CheckBox
                    x:Name="UseExtentCheckBox"
                    Grid.Row="1"
                    Grid.Column="0"
                    Grid.ColumnSpan="2"
                    Margin="0,5,0,0"
                    Checked="UseExtentCheckBox_CheckChanged"
                    Content="Consider current extent"
                    IsChecked="False"
                    Unchecked="UseExtentCheckBox_CheckChanged" />
                <ListView
                    x:Name="TransformationsListBox"
                    Grid.Row="2"
                    Grid.Column="0"
                    Grid.ColumnSpan="2"
                    Height="200"
                    Padding="0"
                    BorderBrush="Black"
                    BorderThickness="1"
                    ItemsSource="{Binding Path=SuitableTransformationsList}"
                    SelectionChanged="TransformationsListBox_Selected">
                    <ListView.ItemTemplate>
                        <DataTemplate x:DataType="local:DatumTransformationListBoxItem">
                            <UserControl>
                                <TextBlock
                                    x:Name="TransformNameTextBlock"
                                    Text="{Binding Path=TransformationObject.Name}"
                                    TextWrapping="Wrap">
                                    <!--  View states to manage display of unavailable transforms, and the default transform.  -->
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup>
                                            <!--  If missing PE files locally, the transform is unavailable.  -->
                                            <VisualState x:Name="UnavailableTransformState">
                                                <VisualState.StateTriggers>
                                                    <StateTrigger IsActive="{x:Bind TransformationObject.IsMissingProjectionEngineFiles}" />
                                                </VisualState.StateTriggers>
                                                <Storyboard>
                                                    <DoubleAnimation
                                                        Storyboard.TargetName="TransformNameTextBlock"
                                                        Storyboard.TargetProperty="(TextBlock.Opacity)"
                                                        To="0.5"
                                                        Duration="0:0:1" />
                                                </Storyboard>
                                            </VisualState>
                                            <!--  One transform is the default, highlight it in blue.  -->
                                            <VisualState x:Name="DefaultTransformState">
                                                <VisualState.StateTriggers>
                                                    <StateTrigger IsActive="{x:Bind IsDefault}" />
                                                </VisualState.StateTriggers>
                                                <Storyboard>
                                                    <ColorAnimation
                                                        Storyboard.TargetName="TransformNameTextBlock"
                                                        Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
                                                        To="Blue"
                                                        Duration="0:0:1" />
                                                </Storyboard>
                                            </VisualState>
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                </TextBlock>
                            </UserControl>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
                <TextBlock
                    x:Name="MessagesTextBox"
                    Grid.Row="3"
                    Grid.Column="0"
                    Grid.ColumnSpan="2"
                    Margin="0,5,0,0"
                    FontWeight="SemiBold"
                    TextWrapping="Wrap" />
            </Grid>
        </Border>
    </Grid>
</UserControl>

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