2

I am trying to set the projections of a .tiff file from another file with GDAL in Python. I successfully set the projections, but how do I re-save the .tiff afterwards?

Here is my code:

ds = gdal.Open('satellite_image.tif')
prj = ds.GetProjection()

roads = gdal.Open('road_lines.tiff')
roads.SetProjection(prj)

1 Answer 1

5

You need to open the second file in update mode, then dereference it to save and close it.

roads = gdal.Open('road_lines.tiff', gdal.GA_Update)
roads.SetProjection(prj)
del roads  # save, close

Another method to apply a projection to a GeoTIFF file is to use the geotifcp utility.

0

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.