reemission.postprocessing.data_processing
Toolbox with functions to assist GIS operations
- class reemission.postprocessing.data_processing.ExtractFromJSON(reemission_output: ~typing.Dict, extracted_keys: ~typing.Dict[str, ~typing.List[str]] = <factory>)[source]
Bases:
object
Extract data from a JSON file and present them in a tabular data format
- __post_init__()[source]
Provide default extracted keys if empty dictionary given as an argument
- extract_outputs() DataFrame [source]
Extract selected RE-Emission gas emission estimation outputs and save them to a dataframe. Calculates and adds additional field ‘tot_em’
- extracted_keys: Dict[str, List[str]]
- classmethod from_file(reemission_file: Path, extracted_keys: Dict[str, List[str]] | None = None) ExtractFromJSON [source]
Instantiate object from data files. :param reemission_file: Output json file from Re-Emission
- reemission_output: Dict
- class reemission.postprocessing.data_processing.ShpToShpCopy(source_data: GeoDataFrame, target_data: GeoDataFrame)[source]
Bases:
object
Opens source and target shape, finds sommon rows (data) based on the match key. For matching keys, adds new fields existing in the source shape and copy the values from source shape to target shape. Overwrites the target shape.
- copy_data(source_key: Any, target_key: Any, fields: List[str]) None [source]
Join two dataframes (source_data and target_data and produce the joined object
- classmethod from_files(source_shp_file: Path, target_shp_file: Path) ShpToShpCopy [source]
Loads source and target shape files from files
- joint_data: GeoDataFrame
- save_joint_data(file_name: Path) None [source]
Save joint data to a shap file
- source_data: GeoDataFrame
- target_data: GeoDataFrame
- class reemission.postprocessing.data_processing.TabToShpCopy(shp_data: GeoDataFrame, tab_data: DataFrame)[source]
Bases:
object
A class for transferring data from a tabular data source to a shape (GIS) data source.
- Parameters
shp_data : GeoDataFrame of shape data tab_data : DataFrame of tabular data
- find_missing_tab_keys(shp_column: Any, tab_column: Any) List[Any] [source]
Find a list of keys that are present in tabular data but are absent in the shape (GIS) data. Common keys are keys that are shared between two datasets in shp_column and tab_column, respectively.
- classmethod from_files(shp_file: Path, tab_file: Path) TabToShpCopy [source]
Loads a shape and tabular data source from files
- save_shp(shp_file_name: Path) None [source]
Saves the shape data to a file
- shp_data: GeoDataFrame
- tab_data: DataFrame
- transfer(source_key_column: Any, target_key_column: Any, fields: List[Any], inplace: bool = True) GeoDataFrame [source]
Transfers data from tabular data source to shape (GIS) data source. Matching data is based on two columns: source_key_column for source data and target_key_column for target data.
- Returns
A GeoDataFrame of the modified shape data.
If inplace is True, the shape data will be modified in place. Defaults to True.
- reemission.postprocessing.data_processing.append_data_to_shapes(shp_folder: Path, data_file: Path, config_dict: Dict, output_folder: Path | None = None, suffix: str = '_updated') None [source]
Appends data from the loaded tabular data into shape files using config information. Uses TabToShpCopy class to copy the selected tabular data to the shape file. Saves modified shape files in the same directory as the original shape files but under a different name. The new name is equal to the original name plus the suffix provided as an argument.
Used to transfer data from GeoCARET csv output file to the shape files.
Functions
|
Appends data from the loaded tabular data into shape files using config information. |
Classes
|
Extract data from a JSON file and present them in a tabular data format |
|
Opens source and target shape, finds sommon rows (data) based on the match key. |
|
A class for transferring data from a tabular data source to a shape (GIS) data source. |