Hi there--
In the ArcGIS Pro SDK for 3.4, we are attempting to save a custom geographic transformation to the current Map.
As an example, the transformation that we are using transforms between the European Datum of 1950 to WGS 1984 by using the position vector method with customize parameters. This is the custom WKT that we have for this transformation:
GEOGTRAN["European Datum (1950) - NW Spain",GEOGCS["GCS_European_1950",DATUM["D_European_1950",SPHEROID["International_1924",6378388.0,297.0]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],METHOD["Position_Vector"],PARAMETER["X_Axis_Translation",-178.4],PARAMETER["Y_Axis_Translation",-83.2],PARAMETER["Z_Axis_Translation",-221.3],PARAMETER["X_Axis_Rotation",0.54],PARAMETER["Y_Axis_Rotation",-0.532],PARAMETER["Z_Axis_Rotation",-0.126],PARAMETER["Scale_Difference",21.2],OPERATIONACCURACY[1.5]]
Then we create the Geographic Transformation using the WKT:
//wkt is equal to the string pasted previously.
GeographicTransformation transform = GeographicTransformation.Create(wkt);
The WKT used above is valid, as it's able to be used for transforming coordinates using the GeometryEngine, for instance.
When we go to store it in the Map, we do the following:
await QueuedTask.Run(() =>
{
CIMMap mapDef = map.GetDefinition();
List<CIMDatumTransform> cimDatumTransforms = mapDef.DatumTransforms.ToList();
//add the previous geographic transformation to the list
CIMDatumTransform newTransform = new CIMDatumTransform()
{
GeoTransformation = transform,
Forward = true
};
cimDatumTransforms.Add(newTransform);
mapDef.DatumTransforms = cimDatumTransforms;
map.SetDefinition(mapDef);
});
The adding of the new transformation occurs without error; if I export the map to a MapX file and open it in a external editor, I can see the custom datum transformation is added to two other transformations generated by Pro for these two datum pairs.
However, when I open the map properties and go to Transformations, then scroll through the list in the combobox, the custom transformation does not show up.
Additionally, we have found that using the Custom Geographic Transformation geoprocessing tool to create the geographic transformation and saving it to a file in %appdata%\ESRI\ArcGISPro\ArcToolbox\CustomTransformations does cause it to be read by the Transformations page and added to the list, as might be expected. However, we would like to avoid this if possible and keep things in memory.
The question then is: Is there a way to add a custom geographic transformation to the map and have it viewable (and selectable) in the map properties' Transformations page without having to use the geoprocessing tool to create a file copy of it?
Thank you,
Matt Winslett
T-Kartor
Solved! Go to Solution.
Hi Matt.
It's tricky to interpret your Transformations page, because it behaves differently when you have live data in your map (like you do) versus when it has broken links (like I do in the .mapx).
But I can tell you about what's in the map, thanks to your .mapx. It has two custom transformations stored in it, and they're both meant to transform between ED50 and WGS84. One is named Test and the other is named European Datum (1950) - NW Spain. This is unusual because Pro expects that the map will contain just one transformation for each unique pair of coordinate systems (so, one for ED50 <--> WGS84, one for WGS84 <--> NAD83, and so on). Pro only shows the first unique one it finds (Test) in the Transformations page, and it discards the other as a duplicate (you may have noticed 4 entries in the .mapx file; that's because we store the transformation once for the "forward" direction and again for the "reverse"). I suggest you open the map in the Transformations page, delete everything you see, and then run your code again, and then see what Transformations shows. It should just show you European Datum (1950) - NW Spain.
More generally: the Transformation page should always show you a custom transformation you're using, but you're right: in order to re-use that transformation in the future, you've got to save it somewhere (using the Custom Geographic Transformation tool).
Pete
Hey Matt, this is Pete from Esri, I'm the developer in that area of the software. Can you paste in a screenshot of the Map Properties dialog when you opened it? I'm trying to understand how the system interpreted your custom transformation.
Also: does your data appear to draw correctly, after adding your custom transformation via the SDK? Or is it difficult to tell?
Finally: could you include a copy of your .mapx file? Even if the data links are broken, it may still be useful.
Generally, yes, you need the Create Custom Geographic Transformation tool to create a transformation that will appear in the drop-down of the transformation page.
Hi Pete --
Thanks for the information. Here is the screenshot you requested, along with a copy of a .mapx file after the custom transformation is added to the map's definition via the SDK. I had to rename the .mapx file with a .txt extension as .mapx files do not appear to be accepted by the Esri community site.
As near as I can tell, it appears that everything draws correctly in the map document. I haven't noticed any issues with layers being misaligned or anything like that.
Thanks,
Matt
Hi Matt.
It's tricky to interpret your Transformations page, because it behaves differently when you have live data in your map (like you do) versus when it has broken links (like I do in the .mapx).
But I can tell you about what's in the map, thanks to your .mapx. It has two custom transformations stored in it, and they're both meant to transform between ED50 and WGS84. One is named Test and the other is named European Datum (1950) - NW Spain. This is unusual because Pro expects that the map will contain just one transformation for each unique pair of coordinate systems (so, one for ED50 <--> WGS84, one for WGS84 <--> NAD83, and so on). Pro only shows the first unique one it finds (Test) in the Transformations page, and it discards the other as a duplicate (you may have noticed 4 entries in the .mapx file; that's because we store the transformation once for the "forward" direction and again for the "reverse"). I suggest you open the map in the Transformations page, delete everything you see, and then run your code again, and then see what Transformations shows. It should just show you European Datum (1950) - NW Spain.
More generally: the Transformation page should always show you a custom transformation you're using, but you're right: in order to re-use that transformation in the future, you've got to save it somewhere (using the Custom Geographic Transformation tool).
Pete
Thanks Pete! With your feedback and information, I was able to get what we are trying to do to work correctly, without having to write the transformation out to disk.
-- Matt
Glad to help. Happy transforming.