AnalyseNetwork

analyse_network.AnalyseNetwork(self, gdf, osm, gtfs, out_path)

Class to calculate transport network using r5py.

Parameters

Name Type Description Default
gdf gpd.GeoDataFrame Geodataframe with the population centroids. required
osm Union[str, pathlib.Path] Path to the location of the open street map file. required
gtfs list List including path or paths to the locations of gtfs files. required
out_path Union[str, pathlib.Path] Path to save the output as parquet files. required

Attributes

Name Type Description
gdf gpd.GeoDataFrame Geodataframe with the population centroids.
out_path Union[str, pathlib.Path] Path to save the output as parquet files.
transport_network TransportNetwork R5py object that contains a transport network initialised with data from OpenStreetMap and GTFS.

Raises

Type Description
NotImplementedError If the out_path provided already contains parquet files, there is a risk that if the number of parquet files produced is less than the number of files in the directory not all of them will be overwritten. This will cause issues when loading them as there will be additional records in the dataframe. In the future we will implement something to handle this (emptying folder, archiving old files). In the meantime, this will raise an error.

Methods

Name Description
od_matrix Calculate full O-D matrix and save as parquet.

od_matrix

analyse_network.AnalyseNetwork.od_matrix(batch_orig=False, partition_size=200, destination_col='within_urban_centre', distance=11.25, unit=Unit.KILOMETERS, **kwargs)

Calculate full O-D matrix and save as parquet.

Parameters

Name Type Description Default
batch_orig bool Flag to indicate whether to calculate the transport network performance using the whole dataset or batching by origin (iteratively calculating the transport performance of each origin and all destinations within range). Should be True for large urban centres where the whole Origin-Destination (O-D) matrix may be too large to be held in memory. Defaults to False. False
partition_size int Maximum size of each individual parquet file. If data exceeds this size, it will be split in several parquet files. 200
destination_col str Column indicating what centroids should be considered as destinations. Default is “within_urban_centre”. 'within_urban_centre'
distance Union[int, float] Distance to filter destinations in km. Points further away from origin are removed from output. Default is 11.25 km. 11.25
unit Unit Unit to calculate distance. Default is km. Unit.KILOMETERS
**kwargs Any valid argument for r5py TravelTimeMatrixComputer object. E.g. departure, max_time, transport_modes. {}

Notes

batch_orig = True can be used for small datasets, however this will likely be slower as normal r5py behaviour uses parallel computing. We recommend setting this argument to True only in cases where memory may not be enough to handle the O-D matrix.