Problem: Translating a set of various rasters with different datum into the same datum using ArcPy
My Solution: Run rasters through a for loop, check their datum with an 'if' statement, run rasters with an unwanted datum through CreateCustomGeoTransformation(), transform these datums to desired datum.
I do not seek advice on how to do this with vector files. These are raster files and they behave differently.
Question: How do I make my fourth parameter, customGeoTransfm, in the tool CreateCustomGeoTransformation() to accept any input datums and run a transformation to a single output datum, if I have to select set translations on the x,y,and z axes?
Script
GCS_Datum All rasters will be transformed into GCS_datum, string input.
geoTransfmName represents the name of the transformation(s)
inGCS represents the datum of each raster in the list in turn
outGCS represents the datum each raster will be transformed into
customGeoTransfm outlines transformation <-- this confuses me
inport arcpy
# start user inputs ----------------
GCS_Datum = "D_North_American_1983"
inFolder = "pathway to workspace"
# end user inputs ------------------
arcpy.env.workspace = inFolder
rasterList = arcpy.ListRasters("*", "ALL")
for raster in rasterList:
geoTransfmName = "thisisatest"
inGCS = arcpy.SpatialReference(raster)
outGCS = arcpy.SpatialReference(GCS_Datum)
#how to make customGeoTransfm universal?
customGeoTransfm = "GEOGTRAN[METHOD['Geocentric_Translation'],PARAMETER['X_Axis_Translation',''],PARAMETER['Y_Axis_Translation',''],PARAMETER['Z_Axis_Translation','']]"
#how to make customGeoTransfm universal?
sr = arcpy.Describe(raster).spatialReference
if sr.GCS.datumName != GCS_Datum:
arcpy.CreateCustomGeoTransformation_management(geoTransfmName, inGCS, outGCS, customGeoTransfm)