pyrsgis.raster.northing¶
- pyrsgis.raster.northing(reference_file, outFile='pyrsgis_northing.tif', value='number', flip=True, dtype='int16', compress=None)[source]¶
Generate northing 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 northing file will be generated.
- outfilestring
Path to the output northing 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 row number of the cells, ‘normalised’ will scale the row number values such that the output raster ranges from 0 to 1. ‘coordinates’ will result in raster that contain the latitude 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.northing(file1, r'E:/path_to_your_file/northing_number.tif', flip=False, value='number')
This will save the file where cells calue represents the row number. Please note that the
flip
parameter defaults toTrue
to replicate the way latitudes increase, that is, from bottom to top.If you want to normalise the output raster, switch the
value
parameter to ‘normalised’. You can switch theflip
parameter as per your requirement.>>> raster.northing(file1, r'E:/path_to_your_file/northing_normalised.tif', value='normalised')
If you want the output file to have the latitude of cell centre, you can change the
value
switch. Please note that theflip
switch will be disabled when exporting as coordinates.>>> raster.northing(file1, r'E:/path_to_your_file/northing_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.northing(file1, r'E:/path_to_your_file/northing_number_compressed.tif', compress='DEFLATE')