make_tree¶
- pyinaturalist.models.make_tree(taxa, include_ranks, sort_key, root_id) Taxon¶
Organize a list of taxa into a taxonomic tree, defined by
childrenandancestorsattributes. Expects exactly one root taxon.- Parameters:
sort_key (
Callable[[Taxon],Any] |None) – Key function for sorting children; defaults to rank and nameinclude_ranks (
list[str] |None) – If provided, only include taxa with these ranks; otherwise, include all ranksroot_id (
int|None) – ID of the root taxon; if provided, only that taxon and its descendants will be included. Otherwise, the root taxon is determined automatically.
- Return type:
- Returns:
Root taxon of the tree