matrix_translation_from_file#
- caf.toolkit.translation.matrix_translation_from_file(matrix_path, zone_correspondence_path, output_path, *, matrix_zone_columns, matrix_values_column, translation_from_column='from', translation_to_column='to', translation_factors_column='factors', format_='long')[source]#
Translate zoning system of matrix CSV file.
Load matrix from CSV, perform translation and write to new CSV. CSV files are expected to be in the matrix ‘long’ format.
- Parameters:
matrix_path (pathlib.Path) – Path to matrix CSV file.
zone_correspondence_path (ZoneCorrespondencePath) – Definition of path and columns to use from translation.
output_path (pathlib.Path) – CSV path to save the translated data to.
matrix_zone_columns (tuple[int | str, int | str]) – Names, or positions, of the 2 columns containing the zone IDs in the matrix file.
matrix_values_column (int | str) – Name, or position, of the column containing the matrix values.
translation_from_col (str = "from") – Name of zone ID column in translation which corresponds to the current vector zone ID. Deprecated, only provide if zone correspondence is a dataframe.
translation_to_col (str = "to") – Name of column in translation for the new zone IDs. Deprecated, only provide if zone correspondence is a dataframe.
translation_factors_col (str = "factors) – Name of column in translation. Deprecated, only provide if zone correspondence is a dataframe.
format (Literal["square", "long"] = "long",) – Whether the matrix is in long or wide format.
translation_from_column (str)
translation_to_column (str)
translation_factors_column (str)
format_ (Literal['square', 'long'])
- Return type:
None