pyrsgis.raster.shift_file¶
- pyrsgis.raster.shift_file(file, shift_type='coordinate', x=0, y=0, outfile=None, dtype='default')[source]¶
Shift and export raster file in one go
This function can export a shifted version of the input raster file.
- Parameters
- filestring
Name or path of the file to be shifted.
- shift_typestring
Available options are ‘coordinates’ and ‘cell’, which correspond to shifting the raster either by the projection units of the raster or by number of cells respectively.
- xnumber
The amount of shift required in x direction (longitude). Please note that this can not be float value if the
shift_type
parameter is set to ‘cell’.- ynumber
The amount of shift required in y direction (latitude). Please note that this can not be float value if the
shift_type
parameter is set to ‘cell’.- outfilestring
Outpt raster file name or path, ideally with a ‘.tif’ extension.
- dtypestring
The data type of the output raster. If nothing is passed, the data type is picked from the
ds
object.
Examples
>>> from pyrsgis import raster >>> infile = r'E:/path_to_your_file/your_file.tif' >>> outfile = r'E:/path_to_your_file/shifted_file.tif' >>> raster.shift_file(infile, x=10, y=10, outfile=outfile)
The exported file will be shifted by 10 units in the x and y directions. You may pass negative values to shift the raster in the opposite direction.
The raster file can also be shifted by number of cells by switching the
shift_type
parameter.>>> raster.shift_file(infile, x=10, y=10, outfile=outfile, shift_type='cell')