pyrsgis.raster.easting¶
- pyrsgis.raster.easting(reference_file, outfile='pyrsgis_easting.tif', value='number', flip=False, dtype='int16', compress=None)[source]¶
Generate easting raster using a reference .tif file
This function generates northing raster from a given raster file.
- Parameters
- reference_filestring
Path to a reference raster file for which the easting file will be generated.
- outfilestring
Path to the output easting file, ideally with ‘.tif’ extension.
- valuestring
The desired value in the output raster. Available options are ‘number’, ‘normalised’ and ‘coordinates’. ‘number’ will result in the column number of the cells, ‘normalised’ will scale the column number values such that the output raster ranges from 0 to 1. ‘coordinates’ will result in raster that contain the longitude of centroid of each cell.
- flipboolean
Whether to flip the resulting raster or not. If
True
, the values in output northing raster will be flipped upside down. Please note that this option is only viable when thevalue
parameter is set to number or normalised. Flipping will not work when thevalue
parameter is set to coordinates.- dtypestring
The data type of the output raster.
- compressstring
Compression type of your output raster. Options are ‘LZW’, ‘DEFLATE’ and other methods that GDAL offers. This is same as the
pyrsgis.raster.export
function.
Examples
>>> from pyrsgis import raster >>> reference_file = r'E:/path_to_your_file/your_file.tif' >>> raster.easting(file1, r'E:/path_to_your_file/easting_number.tif', flip=False, value='number')
This will save the file where cells calue represents the column number. Please note that the
flip
parameter defaults toFalse
to replicate the way longitudes increase, that is, from left to right.If you want to normalise the output raster, switch the
value
parameter to ‘normalised’. You can switch theflip
parameter as per your requirement.>>> raster.easting(file1, r'E:/path_to_your_file/easting_normalised.tif', value='normalised')
If you want the output file to have the longitude of cell centre, you can change the
value
switch. Please note that theflip
switch will be disabled when exporting as coordinates.>>> raster.easting(file1, r'E:/path_to_your_file/easting_coordinates.tif', value='coordinates')
It has been found that significant reduction is disk space usage can be achieved by passing a compression type of the output raster, therefore, doing so is highly recommended. An example of using the
compres
parameter.>>> raster.easting(file1, r'E:/path_to_your_file/easting_number_compressed.tif', compress='DEFLATE')