How to update a parameter with available geographic transformations?

517
5
Jump to solution
02-12-2020 06:26 AM
DanielSuttor
New Contributor II

Hi all,

I have a script that in its first step is supposed to transform a user selected raster to WGS84.

What I'd like to implement in the tool is a string parameter whose value list gets populated with all available geographic transformations from which the user can then select the transformation he desires. Determining the available transformations is easy enough (as descriped here: ListTransformations—Help | ArcGIS Desktop) but I don't know how to use the resulting list as a value list for a parameter in my tool.

It's essentially the same as described here: 

Specify Geographic Transformation as user input in python script 

It's been 9 years since that post and I'm hoping that there's now maybe a way to do this.

0 Kudos
1 Solution

Accepted Solutions
DanielSuttor
New Contributor II

I managed to do it and it was actually very simple, all it took were 4 lines in the ToolValidator:

def updateParameters(self):

   if self.params[0].altered:

      spatial_ref_input = arcpy.Describe(self.params[0]).spatialReference
      transformations = arcpy.ListTransformations(spatial_ref_input, 'WGS 1984')
      self.params[1].filter.list = transformations

View solution in original post

5 Replies
DanPatterson_Retired
MVP Emeritus

There are tool parameters for coordinate system, projection file and spatial reference.  Have you tried the latter to see if a transformation is offered in the process.

0 Kudos
DanielSuttor
New Contributor II
Have you tried the latter to see if a transformation is offered in the process.

It doesn't, or at least not as far as I can tell. This just lets me specify a spatial reference but I already know both spatial references that I need, one gets derived from the input raster and the other is always WGS84.

0 Kudos
DanPatterson_Retired
MVP Emeritus

I know transformations are offered if applicable when using the Project tool, maybe that isn't carried forward within a tool.

I don't have a toolbox tool that used it so I can't test

0 Kudos
DanielSuttor
New Contributor II

I managed to do it and it was actually very simple, all it took were 4 lines in the ToolValidator:

def updateParameters(self):

   if self.params[0].altered:

      spatial_ref_input = arcpy.Describe(self.params[0]).spatialReference
      transformations = arcpy.ListTransformations(spatial_ref_input, 'WGS 1984')
      self.params[1].filter.list = transformations

DanPatterson_Retired
MVP Emeritus

Ahhh !  good one

0 Kudos