dhd.plot

Module to represent graphically the different geometric objects (streets, buildings,…) of the city.

Once instantiated a background graphical interface with the city buildings and the street network is displayed which can be used to plot all the other geometric objects encountered.

Class

class dhd.plot.Plot(streets=None, buildings=None, sources=None, barriers=None, figsize=(9, 6))[source]

Class to define a visual interface representing the city and its constituent geometries.

Parameters:
  • streets (DataFrame, optional) – Dataframe of the streets network with a ‘geometry’ column. Default is None.
  • buildings (DataFrame, optional) – Dataframe of all the city buildings with a ‘geometry’ column. Default is None.
  • sources (DataFrame, optional) – Dataframe of the heating source(s) with a ‘geometry’ column. Default is None.
  • barriers (DataFrame, optional) – Dataframe of the natural barriers with a ‘geometry’ column. Default is None.
  • figsize (tuple) – Size of the figure framework. Default is figsize = (9,6).
add_geodataframe(gdf, kwargs={'color': 'C1'}, centroid=False)[source]

Add the geometries of the geodataframe gdf to the interface.

Parameters:
  • gdf (GeoDataFrame) – Geodataframe of the objects to represent visually.
  • kwargs (dict, optional) – Arguments of the geopandas plot function. Default is {‘color’:’C1’}.
  • centroid (bool) – If True only the centroid of the geometries is represented.
add_legend(colors, labels, type, loc='best')[source]

Add a legend to the interface.

Parameters:
  • colors (list) – List of colors.
  • labels (list) – List of labels.
  • type (string) – Type of legend handle. It may be ‘pach’, ‘line’ or ‘point’.
  • loc (tuple, optional) – Location of the legend box. Default is loc = (0,1).
clear()[source]

Clear all the objects on the interface.

get_handles(colors, labels, type)[source]

Obtain the legend handles for the list of colors and labels.

Parameters:
  • colors (list) – List of colors.
  • labels (list) – List of labels.
  • type (string) – Type of legend handle. It may be ‘pach’, ‘line’ or ‘point.’
Returns:

List of legend handles.

Return type:

list

get_main_handles()[source]

List the handles of the background geometries of the city for the interface legends.

Returns:List of legend handles.
Return type:list
init_barriers(barriers)[source]

Initilization of the barriers geodataframe if barriers is not None.

Parameters:barriers (DataFrame) – Dataframe of the barriers with a ‘geometry’ column.
Returns:Geodataframe of the barriers.
Return type:GeoDataFrame
init_buildings(buildings)[source]

Initilization of the buildings geodataframe if buildings is not None.

Parameters:buildings (DataFrame) – Dataframe of the buildings with a ‘geometry’ column.
Returns:Geodataframe of the buildings.
Return type:GeoDataFrame
init_sources(sources)[source]

Initilization of the sources geodataframe if sources is not None.

Parameters:sources (DataFrame) – Dataframe of the sources with a ‘geometry’ column.
Returns:Geodataframe of the sources.
Return type:GeoDataFrame
init_streets(streets)[source]

Initilization of the streets geodataframe if streets is not None.

Parameters:streets (DataFrame) – Dataframe of the streets network with a ‘geometry’ column.
Returns:Geodataframe of the streets network.
Return type:GeoDataFrame
plot(loc='lower right')[source]

Plot the background geometries of the city which are provided.

reset(loc='lower right')[source]

Reset the interface with only the background geometries.

reset_barriers(barriers)[source]

Reset the class attribute barriers.

Parameters:barriers (DataFrame) – Dataframe of the barriers with a ‘geometry’ column.
reset_sources(sources)[source]

Reset the class attribute sources.

Parameters:sources (DataFrame) – Dataframe of the sources with a ‘geometry’ column.