For the sake of explanation let's call your original geotiff
source.tif and the manipulated version
target.tif. If you use the tool
arcpy.management.ExportRasterWorldFile in conjunction with
source.tif it will create a world file called
source.tfw that contains the tiff's georeferencing information. Assuming that
target.tif has the same pixel size, extent and projection as the source version you can rename the world file to
target.tfw and place it in the same directory as the target tiff and applications such as
gdal, etc. will then implicitly know to obtain spatial reference information for the target raster from the world file.
However, world files don't contain the projection of the raster and that must be defined in separate step, which can be done with
arcpy.management.DefineProjection. The script below executes both of these processes. To adapt the code to your project set the variable
source_tif to the raster that has spatial reference information defined and set
target_folder to a folder containing the tiffs that need their spatial reference defined. Note that any file with a
.tif extension in the target folder will be modified by the script:
from os import path
from arcpy import management
source_tif = 'P:/ath/to/src/geotiff/src_raster.tif'
target_folder = 'P:/ath/to/target/folder'
"""Transfer spatial reference information from a a source raster to a set of
other rasters that have the same spatial reference values, but for which that
information is not defined"""
# create world file from source raster
src_world_file = re.sub('\.tif$', '.tfw', source_tif)
# get source raster projection
src_tiff_srs = arcpy.Describe(source_tif).spatialReference
for tiff in os.listdir(target_folder):
if re.match('.+\.tif$', tiff):
# rename and copy world file to target tiffs
world_file_name = re.sub('\.tif$', '.tfw', tiff)
new_world_file = path.join(target_folder, world_file_name)
# define projection for target tiffs
tiff_path = path.join(target_folder, tiff)