Technical documentation¶
Raster¶
-
class
rasterpy.
Raster
(filename=None, path=None, extension=None, check_dim=True)[source]¶ Import a binary file of ENVI or PolSARpro or a tif to a raster object.
Parameters: - filename (str or tuple, optional) – Filename as a string or a tuple with filenames of the raster data.
- path (str, optional) – Path to raster data. If path is None the path will set to current directory with os.getwd().
- extension (str, optional) – If you want to import all files in a directory with a specific extension, set filename to None and define an extension like ‘.tiff’ or ‘.bin’.
- check_dim (bool) – If True the imported files must have the same dimensions.
-
raster
¶ osgeo.gdal.Dataset – Contains the gdal data set for the raster files.
-
cols, rows
int or tuple – Columns and row size of the imported raster files.
-
band
¶ int or tuple – Number of bands in each raster file.
-
dim
¶ list or tuple – Information about the dimension. It contains [rows, cols, bands].
-
dtype
¶ str or tuple – Gdal data types.
-
projection
¶ str or tuple – Information about the projection of each raster file.
-
xmin, ymin
int or tuple – Origen of x and y pixel.
-
xres, yres
int or tuple – Resulution information in x and y axis.
-
nodata
¶ No data values.
-
info
¶ dict – All information in a dictionary.
-
static
BRDF
(BSC, iza, vza, angle_unit='RAD')[source]¶ Convert a Radar Backscatter Coefficient (BSC) into a BRDF.
Parameters: - BSC (int, float or array_like) – Radar Backscatter Coefficient (sigma 0).
- iza (int, float or array_like) – Sun or incidence zenith angle.
- vza (int, float or array_like) – View or scattering zenith angle.
- angle_unit ({'DEG', 'RAD'} (default = 'RAD'), optional) –
- ‘DEG’: All input angles (iza, vza, raa) are in [DEG].
- ’RAD’: All input angles (iza, vza, raa) are in [RAD].
Returns: BRDF value
Return type: int, float or array_like
-
static
BRF
(BRDF)[source]¶ Convert a BRDF into a BRF.
Parameters: BRDF (int, float or array_like) – BRDF value. Returns: BRF value Return type: int, float or array_like
-
static
BSC
(BRDF, iza, vza, angle_unit='RAD')[source]¶ Convert a BRDF in to a Radar Backscatter Coefficient (BSC).
Parameters: - BSC (int, float or array_like) – Radar Backscatter Coefficient (sigma 0).
- iza (int, float or array_like) – Sun or incidence zenith angle.
- vza (int, float or array_like) – View or scattering zenith angle.
- angle_unit ({'DEG', 'RAD'} (default = 'RAD'), optional) –
- ‘DEG’: All input angles (iza, vza, raa) are in [DEG].
- ’RAD’: All input angles (iza, vza, raa) are in [RAD].
Returns: BRDF value
Return type: int, float or array_like
-
convert
(system='BSC', to='BRDF', system_unit='linear', output_unit='linear', iza=None, vza=None, angle_unit='RAD')[source]¶ Convert the data from BSC, BRDF, BRF to BRDF, BSC or BRF.
Parameters: - system ({'BSC', 'BRDF', 'BRF'}) – The actual unit of the data. Default is ‘BSC’.
- to ({'BSC', 'BRDF', 'BRF'}) – The desired unit after conversion. Default is ‘BRDF’
- system_unit ({'linear', 'dB'}, optional) – Are the measurements in a linear scale or in decibel? Default is ‘linear’.
- output_unit ({'linear', 'dB'}, optional) – The desired output format. Default is ‘linear’.
- iza (int, float, array_like or None, , optional) – Sun or incidence zenith angle. Default is None.
- vza (int, float, array_like or None, optional) – View or scattering zenith angle.
- angle_unit ({'DEG', 'RAD'}, optional) –
- ‘DEG’: All input angles (iza, vza, raa) are in [DEG] (default).
- ’RAD’: All input angles (iza, vza, raa) are in [RAD].
Returns: Return type: None
-
copy
()[source]¶ Copy the imported array.
Returns: copy – A copy of Raster.array attribute. Return type: array_like or tuple
-
dstack
(unfold=False)[source]¶ Stack 1-D arrays as columns into a 2-D array. Take a sequence of 1-D arrays and stack them as columns to make a single 2-D array. 2-D arrays are stacked as-is, just like with numpy.hstack. 1-D arrays are turned into 2-D columns first.
Parameters: unfold (bool, optional) – If the arrays are multi dimensional this option extracts the individual dimension and stack it to an array. Default is False. -
stack
¶ array_like – Stacked array.
-
-
set_nodata
(nodata)[source]¶ Set and assign a new no data value.
Parameters: nodata (int, float or np.nan) – New no data value. A tuple with in, float or np.nan is also possible if you imported more than one file. Returns: Return type: None
-
to_array
(band=None, flatten=True, quantification_factor=1)[source]¶ Converts a binary file of ENVI or PolSARpro or a tif to a numpy array.
Parameters: - band (int, tuple or None, optional:) – Define bands which you want to import. If None (default) import all bands in a multidimensional array. You can also specify bands in a tuple. E.g. band=(1, 3) will load the first and third band of the image.
- flatten (bool) – if flatten is True the output array is one dimensional. You can convert it to an 2 dimensional array with Raster.reshape
- quantification_factor (int, optional) – A quantification factor that scales the reflectance values from 0 to 1. It is only required if the imported raster files are reflectance values. For sentinel 2 the factor is 10000. Default is 1, which have no effect.
-
array
¶ array_like or tuple with array_likes – Raster files as arrays.
-
write
(data, filename, path=None, reference=0)[source]¶ Convert an array into a binary (.bin) file with header (.hdr) or a Tif file.
Parameters: - data (array_like or tuple) – Arrays you want to export.
- filename (str or tuple) – File names of the exported arrays. Supported file extension are ‘.tif’ or ‘.bin’
- path (str, optional) – Export path. If path is None the path will set to current directory with os.getwd().
- reference – If the Raster import contains several grids, you can specify which of these grids you want to use as reference for geo-spatial information (default=0).
Returns: Return type: Grid as .tif or bin