qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.34k stars 2.98k forks source link

Raster shift tool #42818

Open akypar opened 3 years ago

akypar commented 3 years ago

I think it would be very useful if anyone could develop a tool like "Vector geometry/Translate" for rasters, i.e. capable to move a raster layer by offsetting with a specified x and y displacement. Thanks!!

chkaval commented 3 years ago

I would certainly agree. There is no straight way to shift a raster in Q but this is an ultimate need. Freehand Raster Georeference is an option but it is working somehow manually and you can't shift multiple rasters at an exactly same offset.

jakimowb commented 3 years ago

Just because I used it yesterday, this python script shifts an image by 25.3, -1.2 coordinate system units:

path_source = r'path/unshifted.tif'
path_shifted = r'path/shifted.vrt'
shift_x, shift_y = 25.3, -1.2
ds: gdal.Dataset = gdal.Translate(path_shiftes, path_source, options=gdal.TranslateOptions(format='VRT'))
gt = list(ds.GetGeoTransform())
gt[0] = gt[0] + shift_x
gt[3] = gt[3] + shift_y
ds.FlushCache()

As the output is of type VRT, you can compare shifted and original image without doubling the required disk space

akypar commented 3 years ago

Thank you jakimowb!

This is a solution indeed, but for non python users would be rather complicated...

I thouht that such a simple task would be easily developed as a QGIS tool assesible for simple end users, since there is already a similar tool for vectors.

On 16-Apr-21 13:17, jakimowb wrote:

Just because I had to do so yesterday, you could use´this python script to shift an image (in coordinate system units).

|path_source = r'path/unshifted.tif' path_shifted = r'path/shifted.vrt' shift_x, shift_y = 25.3, -1.2 ds: gdal.Dataset = gdal.Translate(path_shiftes, path_source, options=gdal.TranslateOptions(format='VRT')) gt = list(ds.GetGeoTransform()) gt[0] = gt[0] + shift_x gt[3] = gt[3] + shift_y ds.FlushCache() |

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/qgis/QGIS/issues/42818#issuecomment-821074266, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATWOI32L2ZS6EAXP7AJX6H3TJAFB5ANCNFSM43AZ6ZPA.

gioman commented 3 years ago

@akypar you may want to consider porting to QGIS 3 this plugin https://github.com/geodrinx/rasmover

akypar commented 3 years ago

I have tried that, but the pluggin cannot be installed in QGIS 3.xx:

Couldn't load plugin 'rasmover-master' due to an error when calling its classFactory() method

This plugin is incompatible with this version of QGIS Plugin designed for QGIS 2.0 - 2.99

On 16-Apr-21 15:31, Giovanni Manghi wrote:

@akypar https://github.com/akypar you may want to consider porting to QGIS 3 this plugin https://github.com/geodrinx/rasmover https://github.com/geodrinx/rasmover

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/qgis/QGIS/issues/42818#issuecomment-821140955, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATWOI3ZAIFNA4TSSYC7JBMLTJAUZPANCNFSM43AZ6ZPA.

roya0045 commented 3 years ago

Gdal move exists but is not a tool.

gioman commented 3 years ago

Gdal move exists but is not a tool.

@roya0045 seems different. The above suggested plugins allowed to shift a raster without changing its CRS.

gioman commented 3 years ago

I have tried that, but the pluggin cannot be installed in QGIS 3.xx:

@akypar in fact I said you could consider porting it to QGIS 3, as it does what you need.

jratike80 commented 2 years ago

This rasmover fork works with QGIS 3.18 https://github.com/mitkin/rasmover I found it very useful with scanned and georeferenced historical maps which tend to need some fine tuning.

dkonda42 commented 2 years ago

You can create a VRT and shift the raster by editing it in notepad.

https://gis.stackexchange.com/questions/112031/shifting-image-in-a-vrt