I'm trying to shift a georeferenced raster by 0.5m N and 0.5m W in QGIS using the python console:
from osgeo import gdal # Open in read/write mode rast_src = gdal.Open('test_raster.tif', 1) # Get affine transform coefficients gt = rast_src.GetGeoTransform() # Convert tuple to list, so we can modify it gtl = list(gt) gtl[0] -= 0.5 # Move west 0.5 m gtl[3] += 0.5 # Move north 0.5 m # Save the geotransform to the raster rast_src.SetGeoTransform(tuple(gtl)) rast_src = None # equivalent to save/close However line #7 (gt = rast_src.GetGeoTransform()) throws an AttributeError: 'NoneType' object has no attribute 'GetGeoTransform'. The installed GDAL version is 1.11.0. The raster seems fine. So what's wrong?
أكثر...
from osgeo import gdal # Open in read/write mode rast_src = gdal.Open('test_raster.tif', 1) # Get affine transform coefficients gt = rast_src.GetGeoTransform() # Convert tuple to list, so we can modify it gtl = list(gt) gtl[0] -= 0.5 # Move west 0.5 m gtl[3] += 0.5 # Move north 0.5 m # Save the geotransform to the raster rast_src.SetGeoTransform(tuple(gtl)) rast_src = None # equivalent to save/close However line #7 (gt = rast_src.GetGeoTransform()) throws an AttributeError: 'NoneType' object has no attribute 'GetGeoTransform'. The installed GDAL version is 1.11.0. The raster seems fine. So what's wrong?
أكثر...