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?


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)

1 Answer 1


So I believe I've found an answer to this question. My original problem was based in a fundamental misunderstanding of how ESRI's ArcGIS handles datums.

There are only a certain number of available datum transformations from a Datum A to Datum B, many of which can be found in this pdf: http://help.arcgis.com/en/arcgisdesktop/10.0/help/003r/pdf/geographic_transformations.pdf
Contrary to my belief, ArcPy does not have tools with the mathematical functionalty to do universal datum translations between any datum and any other datum. This must be done using 1) a pre assigned datum translation or 2) a wholly customized datum translation.

WGS_1984 is a very common "Common Denominator" which is used to translate between datums. Often Datum A is translated to WGS_1984 which is then translated to Datum B, so potentially I could write my code such that the input raster datum was then translated to WGS1984 and then automatically translated to datum B. This would work maybe 60% of the time. I found more information about this from @U2ros Datum transformations, do we use wgs84 as an intermediate common reference? and @nickponline When is data created in datums other than WGS84?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.