iduedu.diversity

iduedu.diversity(urban_graph, cutoff, category, *, gdf_objects, gdf_origins=None, origins_nodes=None, values=None, hill_order=2.0, weight='time_min', decay=None, beta=None, direction='from', graph_node_column='graph_node_id', max_workers=None)[source]

Diversity of object categories within a travel cost of every origin.

The shares p of the categories are taken from the object counts in reach (or from the sums of values, for example floor area), weighted by decay when it is set.

Parameters:
  • urban_graph (UrbanGraph) – Graph to search.

  • cutoff (Union[float, Iterable[float]]) – Largest travel cost, inclusive, or several of them.

  • category (str) – Column of gdf_objects with the category of every object. Objects without one are left out.

  • gdf_objects (DataFrame) – Objects, with graph_node_column or matched to their nearest nodes.

  • gdf_origins (DataFrame | None) – Origin objects, with the same conventions, or

  • origins_nodes (Optional[Iterable[Any]]) – origin node ids.

  • values (str | None) – Numeric column of gdf_objects that weighs the objects instead of counting them.

  • hill_order (float) – Order q of the Hill number: 0 counts categories, 1 gives exp of the Shannon entropy, 2 (the default) the inverse Simpson index.

  • weight (Literal['length_meter', 'time_min']) – Edge cost column: time_min (minutes) or length_meter (metres).

  • decay (Optional[Literal['linear', 'exp', 'inverse']]) – Distance decay, see aggregate_objects().

  • beta (Union[float, Iterable[float], None]) – Rate of the exponential decay, see aggregate_objects().

  • direction (Literal['from', 'to']) – "from" (origin to object) or "to" (object to origin).

  • graph_node_column (str) – Column of object tables that holds graph node ids.

  • max_workers (int | None) – Number of threads; None uses all cores.

Returns:

richness_c (categories in reach), shannon_c (entropy -Σ p ln p) and hill_c (effective number of categories of order hill_order); NaN for the last two where nothing is in reach.

Return type:

DataFrame indexed like the origins. For every cutoff c

Raises:
  • KeyError – If category or values is absent from gdf_objects.

  • ValueError – If hill_order is negative or other arguments are invalid.