api.measures

api.measures

Functions

Name Description
calculate_polygon_area Calculate the area of a polygon from a GeoDataFrame.
calculate_volume Calculate the volume of green infrastructure based on the given area, height, and percent area.
copy_measure Copy an event in the database.
create_measure Create a measure from a dictionary of attributes and a type string.
delete_measure Delete an event from the database.
edit_measure Edit an event object in the database.
get_green_infra_table Return a table with different types of green infrastructure measures and their infiltration depths.
get_measure Get a measure from the database by name.
get_measures Get all measures from the database.
save_measure Save an event object to the database.

calculate_polygon_area

api.measures.calculate_polygon_area(gdf, site)

Calculate the area of a polygon from a GeoDataFrame.

Parameters

Name Type Description Default
gdf gpd.GeoDataFrame A GeoDataFrame containing the polygon geometry. required
site ISite An instance of ISite representing the site information. required

Returns

Name Type Description
float: The area of the polygon in the specified units.

calculate_volume

api.measures.calculate_volume(
    area,
    height=us.UnitfulHeight(value=0.0, units=us.UnitTypesLength.meters),
    percent_area=100.0,
)

Calculate the volume of green infrastructure based on the given area, height, and percent area.

Parameters

Name Type Description Default
area float The area of the green infrastructure in square units. required
height float The height of the green infrastructure in units. Defaults to 0.0. us.UnitfulHeight(value=0.0, units=us.UnitTypesLength.meters)
percent_area float The percentage of the area to be considered. Defaults to 100.0. 100.0

Returns

Name Type Description
float: The calculated volume of the green infrastructure.

copy_measure

api.measures.copy_measure(old_name, new_name, new_description)

Copy an event in the database.

Parameters

Name Type Description Default
old_name str The name of the event to copy. required
new_name str The name of the new event. required
new_description str The description of the new event required

create_measure

api.measures.create_measure(attrs, type=None)

Create a measure from a dictionary of attributes and a type string.

Parameters

Name Type Description Default
attrs dict[str, Any] Dictionary of attributes for the measure. required
type str Type of measure to create. None

Returns

Name Type Description
IMeasure Measure object.

delete_measure

api.measures.delete_measure(name)

Delete an event from the database.

Parameters

Name Type Description Default
name str The name of the event to delete. required

Raises

Name Type Description
ValueError If the event does not exist.

edit_measure

api.measures.edit_measure(measure)

Edit an event object in the database.

Parameters

Name Type Description Default
measure IMeasure The measure object to edit. required

Raises

Name Type Description
ValueError If the event object does not exist.

get_green_infra_table

api.measures.get_green_infra_table(measure_type)

Return a table with different types of green infrastructure measures and their infiltration depths.

Parameters

Name Type Description Default
measure_type str The type of green infrastructure measure. required

Returns

Name Type Description
pd.DataFrame A table with different types of green infrastructure measures and their infiltration depths.

get_measure

api.measures.get_measure(name)

Get a measure from the database by name.

Parameters

Name Type Description Default
name str The name of the measure to retrieve. required

Returns

Name Type Description
IMeasure The measure object with the given name.

Raises

Name Type Description
ValueError If the measure with the given name does not exist.

get_measures

api.measures.get_measures()

Get all measures from the database.

Returns

Name Type Description
dict[str, Any] A dictionary containing all measures. Includes keys: ‘name’, ‘description’, ‘path’, ‘last_modification_date’, ‘objects’ Each value is a list of the corresponding attribute for each measure.

save_measure

api.measures.save_measure(measure)

Save an event object to the database.

Parameters

Name Type Description Default
measure IMeasure The measure object to save. required

Raises

Name Type Description
ValueError If the event object is not valid.
Back to top