saferoad.saferoad module

class saferoad.saferoad.PsData(filepath: str, latitude: str, longitude: str, unit: Literal['m', 'cm', 'mm'] = 'm', crs_code: str = 'EPSG:4326', name: str = 'pspoint')[source]

Bases: object

Class for storing point source data information.

Parameters:
  • filepath (str) – Path to the point source data file.

  • latitude (str) – Field name of the latitude field in the data file.

  • longitude (str) – Field name of the longitude field in the data file.

  • unit (Literal["m", "cm", "mm"]) – Unit of measurement for the coordinates. Options are “m”, “cm”, or “mm”. Default is “m”.

  • crs_code (str) – Coordinate Reference System code. Default is “EPSG:4326”.

  • name (str) – Name identifier for the point source data. Default is “pspoint”.

crs_code: str = 'EPSG:4326'
filepath: str
latitude: str
longitude: str
name: str = 'pspoint'
unit: Literal['m', 'cm', 'mm'] = 'm'
class saferoad.saferoad.Road(filepath: str, crs_code: str = 'EPSG:4326', name: str = 'road')[source]

Bases: object

Class for storing road data information.

Parameters:
  • filepath (str) – Path to the road data file.

  • crs_code (str) – Coordinate Reference System code. Default is “EPSG:4326”.

  • name (str) – Name identifier for the road data. Default is “road”.

crs_code: str = 'EPSG:4326'
filepath: str
name: str = 'road'
class saferoad.saferoad.SafeRoad(road: Road, ps_data: PsData, computational_crs: str)[source]

Bases: object

A class to perform road deformation analysis using MT-InSAR data.

Parameters:
  • road (Road) – An instance of the Road class containing road data information.

  • ps_data (PsData) – An instance of the PsData class containing MT-InSAR data information.

  • computational_crs (str) – A string representing the EPSG code for the computational CRS.

generate_rectangles(road_width: float, segment_length: float)[source]

Generate road segments and patches.

This involves: 1. Splitting the road into segments of equal length. 2. Generating rectangles along the road segments with a specified width. 2. Rotating the generated rectangles int the same direction along the road.

Parameters:
  • road_width – A float representing the width of the road segments in meters.

  • segment_length – A float representing the length of each road segment in meters.

generate_report(output_name: str)[source]

Generate a PDF report containing maps and time series plots.

Parameters:

output_name (str) – A string representing the name of the output PDF file endswith .pdf extension.

load_files()[source]

Load the road and MT-InSAR data files into the database.

preprocess(attribute: str | None = None)[source]

Preprocess the road and MT-InSAR data.

This includes transforming the data to the computational CRS, dissolving road features, and building geometries for the MT-InSAR points. 1. Transform the road and MT-InSAR data to the computational CRS. 2. Dissolve road features based on the provided attribute if given, otherwise merge all features. 3. Build geometries for the MT-InSAR points from the latitude and longitude columns. 4. Transform the MT-InSAR data to the computational CRS.

Parameters:

attribute (str, optional) – An optional string representing the attribute to dissolve road features. If None, all features will be merged. Default is None.

run_analysis()[source]

Run the deformation analysis on the MT-InSAR data for road network.

This includes calculating cumulative displacement, average velocity, point density, local control points, and outliers.