dhd.modify

Module to search, select and modify specific streets or sinks from the dataframe streets or sinks.

The visual matplotlib interface of the module dhd.plot can be used to localize geometric object on the map.

Inputs

The functions are designed to work on the dataframes streets and sinks which can be obtained from the methods dhd.city.City.get_streets() and dhd.city.City.get_sinks().

Functions

dhd.modify.add_sinks(sinks, sinks_to_add, ignore_index=True)[source]

Add new sinks to the dataframe sinks.

Parameters:
  • sinks (DataFrame) – Dataframe of the sinks.
  • sinks_to_add (DataFrame) – Dataframe of the sinks to add.
  • ignore_index (bool, optional) – If True, reset the indices to integers, else use the indices provided. Default is True.
Returns:

Appended dataframe of the sinks.

Return type:

DataFrame

dhd.modify.add_streets()[source]

TODO

dhd.modify.find_sinks(sinks, p, R=1, plot=None)[source]

Find the sinks within the distance R from the given point p.

Plot the selection of sinks on the axes of the dhd.plot.Plot instance plot if provided.

Parameters:
  • sinks (DataFrame) – Dataframe of the sinks.
  • p (Point or tuple) – Coordinates of the given point.
  • R (float, optional) – Maximal distance from the point so that a street is selected. Default is 1 meter.
  • plot (dhd.plot.Plot, optional) – Plot instance associated to the considered city. Default is None.
Returns:

Dataframe of the selected sinks with indices from the dataframe sinks.

Return type:

DataFrame

dhd.modify.find_streets(streets, p, R=1, plot=None)[source]

Find the streets within the distance R from the given point p.

Plot the selection of streets on the axes of the dhd.plot.Plot instance plot if provided.

Parameters:
  • streets (DataFrame) – Dataframe of the streets network.
  • p (Point or tuple) – Coordinates of the given point.
  • R (float, optional) – Maximal distance from the point so that a street is selected. Default is 1 meter.
  • plot (dhd.plot.Plot, optional) – Plot instance associated to the considered city. Default is None.
Returns:

Dataframe of the selected streets with indices from the dataframe streets.

Return type:

DataFrame

dhd.modify.find_streets_mutiple_points(streets, points, R=1, plot=None)[source]

Find the streets within the distance R from the given list of points points.

Plot the selection of streets on the axes of the dhd.plot.Plot instance plot if provided.

Parameters:
  • streets (DataFrame) – Dataframe of the streets network.
  • points (list of Point or tuple) – Coordinates of the given points.
  • R (float, optional) – Maximal distance from the point so that a street is selected. Default is 1 meter.
  • plot (dhd.plot.Plot, optional) – Plot instance associated to the considered city. Default is None.
Returns:

Dataframe of the selected streets with indices from the dataframe streets.

Return type:

DataFrame

dhd.modify.get_sinks_selection(sinks, p, R)[source]

Select the sinks from the dataframe sinks within the distance R from the given point p.

Parameters:
  • sinks (DataFrame) – Dataframe of the sinks.
  • p (Point or tuple) – Coordinates of the given point.
  • R (float, optional) – Maximal distance from the point so that a street is selected.
Returns:

Dataframe of the selected sinks with indices from the dataframe sinks.

Return type:

DataFrame

dhd.modify.get_streets_selection(streets, p, R)[source]

Select the streets from the dataframe streets within the distance R from the given point p.

Parameters:
  • streets (DataFrame) – Dataframe of the streets network.
  • p (Point or tuple) – Coordinates of the given point.
  • R (float, optional) – Maximal distance from the point so that a street is selected.
Returns:

Dataframe of the selected streets with indices from the dataframe streets.

Return type:

DataFrame

dhd.modify.multiply_sinks_load(sinks, indices, ratios)[source]

Multiply the loads of the rows of the dataframe sinks with the given indices by the given ratios ; in-place.

indices and ratios may either be singlets of lists.

Parameters:
  • sinks (DataFrame) – Dataframe of the sinks.
  • indices (int or list) – Index (or indices) of the sink(s) which load shall be changed.
  • ratios (float or list) – Number(s) by which the associated sinks load is multiplied and then replaced.
dhd.modify.multiply_streets_weight(streets, indices, ratios)[source]

Multiply the weights of the rows of the dataframe streets with the given indices by the given ratios ; in-place.

indices and ratios may either be singlets of lists.

Parameters:
  • streets (DataFrame) – Dataframe of the streets network.
  • indices (int or list) – Index (or indices) of the street(s) which weight shall be changed.
  • ratios (float or list) – Number(s) by which the associated street weight is multiplied and then replaced.
dhd.modify.plot_point(p, plot)[source]
dhd.modify.plot_sinks(sinks_selection, plot)[source]

Plot the selected sinks centroids on the axes of the plot instance together with a legend.

Parameters:
  • sinks_selection (DataFrame) – Dataframe of the sinks close enough to the considered point.
  • plot (dhd.plot.Plot) – Plot instance associated to the considered city.
dhd.modify.plot_streets(streets_selection, plot)[source]

Plot the selected streets on the axes of the plot instance together with a legend.

Parameters:
  • streets_selection (DataFrame) – Dataframe of the streets close enough to the considered point.
  • plot (dhd.plot.Plot) – Plot instance associated to the considered city.
dhd.modify.remove_sinks(sinks, index, ignore_index=True)[source]

Remove sinks to the dataframe sinks.

Parameters:
  • sinks (DataFrame) – Dataframe of the sinks.
  • index (list) – List of indices of the sinks to remove.
  • ignore_index (bool, optional) – If True, reset the indices to integers, else use the indices provided. Default is True.
Returns:

Updated dataframe of the sinks.

Return type:

DataFrame

dhd.modify.remove_streets(streets, index)[source]

Remove streets to the dataframe streets.

Parameters:
  • streets (DataFrame) – Dataframe of the streets.
  • index (list) – List of indices of the streets to remove.
Returns:

Updated dataframe of the streets.

Return type:

DataFrame

dhd.modify.replace_sinks_load(sinks, indices, loads)[source]

Replace the loads of the rows of the dataframe sinks with the given indices by the given loads ; in-place.

indices and loads may either be singlets of lists.

Parameters:
  • sinks (DataFrame) – Dataframe of the sinks.
  • indices (int or list) – Index (or indices) of the sink(s) which load shall be changed.
  • loads (float or list) – Number(s) by which the associated sinks load are replaced.
dhd.modify.replace_streets_weight(streets, indices, weights)[source]

Replace the weights of the rows of the dataframe streets with the given indices by the given weights ; in-place.

indices and weights may either be singlets of lists.

Parameters:
  • streets (DataFrame) – Dataframe of the streets network.
  • indices (int or list) – Index (or indices) of the street(s) which weight shall be changed.
  • weights (float or list) – Number(s) by which the associated street weight are replaced.