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.
Solved! Go to Solution.
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
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.
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.
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
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
Ahhh ! good one