remotior_sensus.core.table_manager module
Table manager.
This tool allows for managing table data as NumPy structured arrays. It includes functions for field calculation, join and pivot tables. Also, functions to manage tables used in other tools are included. Tables can be exported to csv files.
Typical usage example:
>>> # import Remotior Sensus and start the session
>>> import remotior_sensus
>>> rs = remotior_sensus.Session()
>>> # open a file
>>> file1 = 'file1.csv'
>>> table1 = rs.table_manager.open_file('file1.csv', field_names=['field1', 'field2'])
>>> # perform a calculation
>>> calculation = rs.table_manager.calculate(
... matrix=table1, expression_string='"field1" * 1.5',
... output_field_name='calc'
... )
>>> # export the table to csv
>>> rs.table_manager.export_table(
... matrix=calculation, output_path='output.csv',
... fields=['field1', 'calc'], separator=';', decimal_separator='.'
... )
- remotior_sensus.core.table_manager.add_product_to_preprocess(product_list, spacecraft_list, processing_level, band_name_list, product_path_list, scale_list, offset_list, nodata_list, date_list, k1_list, k2_list, band_number_list, e_sun_list, sun_elevation_list, earth_sun_distance_list)
- remotior_sensus.core.table_manager.add_spectral_signature_to_catalog_table(signature_id=None, macroclass_id=0, class_id=0, class_name=None, previous_catalog=None, selected=1, min_dist_thr=0, max_like_thr=0, spec_angle_thr=0, geometry=0, signature=0, color_string=None, pixel_count=0, unit=None)
- remotior_sensus.core.table_manager.append_field(matrix, field_name, data, data_type)
- remotior_sensus.core.table_manager.append_tables(matrix1, matrix2)
- remotior_sensus.core.table_manager.append_values_to_table(matrix, value_list)
- remotior_sensus.core.table_manager.calculate(matrix, expression_string, output_field_name, progress_message=True)
- Parameters:
matrix – input matrix
expression_string – string used for calculation where fields must be named using double quotes e.g.”field_name” or using ‘field.’ such as field.field_name or ‘matrix.’ such as matrix.field_name
output_field_name – string of output field name
progress_message – optional, if True display process message
- remotior_sensus.core.table_manager.calculate_multi(matrix, expression_string_list, output_field_name_list, progress_message=True)
- Parameters:
matrix – input matrix
expression_string_list – list of strings used for calculation where fields must be named using double quotes e.g.”field_name” or using ‘field.’ such as field.field_name or ‘matrix.’ such as matrix.field_name
output_field_name_list – list of strings of output field names
progress_message – optional, if True display process message
- remotior_sensus.core.table_manager.columns(matrix)
- remotior_sensus.core.table_manager.create_band_table(band_number=0, raster_band=None, path=None, name=None, wavelength=0, wavelength_unit=None, additive_factor=0, multiplicative_factor=1, date='1900-01-01', x_size=0, y_size=0, top=0, left=0, bottom=0, right=0, x_count=0, y_count=0, nodata=None, data_type=None, crs=None, root_directory=None, number_of_bands=0, x_block_size=0, y_block_size=0, scale=None, offset=None)
- remotior_sensus.core.table_manager.create_bandset_catalog_table(bandset_number=0, root_directory=None, date='NaT', bandset_uid=0, bandset_name=None, previous_catalog=None, crs=None, box_coordinate_left=None, box_coordinate_top=None, box_coordinate_right=None, box_coordinate_bottom=None)
- remotior_sensus.core.table_manager.create_bandset_table(band_list)
- remotior_sensus.core.table_manager.create_generic_table(value_list, dtype_list)
- remotior_sensus.core.table_manager.create_product_table(product=None, product_id=None, acquisition_date=None, cloud_cover=None, zone_path=None, row=None, min_lat=None, min_lon=None, max_lat=None, max_lon=None, collection=None, size=None, preview=None, uid=None, image=None, ref_url=None)
- remotior_sensus.core.table_manager.create_spectral_signature_table(value_list, wavelength_list, standard_deviation_list=None)
- remotior_sensus.core.table_manager.define_fields(matrix, field_list)
- remotior_sensus.core.table_manager.export_table(matrix, output_path, fields=None, field_decimals: int | list = 2, separator=None, decimal_separator=None, nodata_value=None, nodata_value_output='nan', progress_message=True)
- Parameters:
matrix – input matrix
output_path – output path
fields – optional list of fields to export
field_decimals – integer number of decimals for decimal fields or list of integer values for decimal fields
separator – separator of fields
decimal_separator – optional decimal separator for float values replacing . character
nodata_value – optional nodata value to be replaced
nodata_value_output – optional string to replace nodata value in output
progress_message
- remotior_sensus.core.table_manager.find_nearest_value(array, field_name, value, threshold=None)
- remotior_sensus.core.table_manager.get_values(matrix, value_field, conditional_string=None, progress_message=True)
- Parameters:
matrix – input matrix
value_field – string of value field name
conditional_string – optional string used for condition where field must be referred to using ‘field.’ such as field.field_name or ‘matrix.’ such as matrix.field_name
progress_message – optional, if True display process message
- remotior_sensus.core.table_manager.join_matrices(matrix1, matrix2, field1_name, field2_name, join_type='leftouter', matrix1_postfix='_m1', matrix2_postfix='_m2', use_mask=False, progress_message=True)
- remotior_sensus.core.table_manager.join_tables(table1, table2, field1_name, field2_name, postfix='2', nodata_value=None, join_type='left', n_processes: int | None = None, progress_message=True, min_progress=None, max_progress=None)
- remotior_sensus.core.table_manager.matrix_to_csv(matrix, output_path, fields=None, field_decimals: int | list = 2, separator=None, decimal_separator=None, nodata_value=None, nodata_value_output='nan', progress_message=True)
- Parameters:
matrix – input matrix
output_path – output path
fields – optional list of fields to export
field_decimals – integer number of decimals for decimal fields or list of integer values for decimal fields
separator – separator of fields
decimal_separator – optional decimal separator for float values replacing . character
nodata_value – optional nodata value to be replaced
nodata_value_output – optional string to replace nodata value in output
progress_message
- remotior_sensus.core.table_manager.open_file(file_path: str, separators: str | list | None = None, field_names: list | None = None, skip_first_line: bool | None = True, progress_message: bool | None = True) recarray
Opens a file.
Opens a file by reading the content and creating a table (which is a NumPy structured array). File formats csv and dbf are supported.
- Parameters:
file_path – path of output file.
separators – list of characters used as separator in csv files; default is tab and comma.
field_names – list of strings to be used as field names.
skip_first_line – skip the first line in csv files, in case the first line contains field names.
progress_message – if True then start progress message; if False does not start the progress message (useful if launched from other tools).
- Returns:
Table as NumPy structured array.
Examples
- Open a file
>>> table_1 = open_file('file.csv')
- remotior_sensus.core.table_manager.pivot_matrix(matrix, row_field, column_function_list, secondary_row_field_list=None, filter_string=None, nodata_value=-999, cross_matrix=None, field_names=False, progress_message=True)
- Parameters:
matrix – matrix array
row_field – field out_column_name of values used as rows
column_function_list – list of lists of column out_column_name and function on values and optional out dtype
secondary_row_field_list – optional list of fields to be used as secondary rows
filter_string – optional string for filtering input matrix values
nodata_value – optional value for nodata
cross_matrix – optional, if True the output table field names are only combination values
field_names – optional, if True returns field names without performing the pivot matrix
progress_message – optional, if True display process message
- remotior_sensus.core.table_manager.redefine_matrix_columns(matrix, input_field_names, output_field_names=None, progress_message=True)
- Parameters:
matrix – matrix array
input_field_names – list of field names to be included in output
output_field_names – optional list of output field names with the same length as input_field_names
progress_message – optional, if True display process message
- remotior_sensus.core.table_manager.rename_field(matrix, old_field, new_field)
- remotior_sensus.core.table_manager.replace_numpy_operators(expression)
- remotior_sensus.core.table_manager.replace_variables(matrix, expression_string)
- remotior_sensus.core.table_manager.sort_table_by_field(matrix, field_name)
- remotior_sensus.core.table_manager.stack_product_table(product_list)