Skip to content

Relation

Bases: Element

Represents a relation with a collection of members.

Together with nodes and ways it represents one of the three main OSM element types. As such, it inherits all attributes and methods from Element.

A relation is effectively a collection of nodes, ways, and relations, where each member has a role within the relationship. A membership of a relation is represented by the Member class.

Attributes:

Name Type Description
type str

The OSM element type. Always "relation".

members list[Member]

A list of the members of the relation.

fetch_full()

Fetches the relation, but with additional information about member elements.

This is required for certain operations such as constructing the geometry of the relation.

Returns:

Type Description
FullRelation

The relation, but with additional information about member elements.

FullRelation

Bases: Relation

The same as relation, but with additional information about member elements.

This is required for certain operations such as constructing the geometry of the relation.

Attributes:

Name Type Description
elements list[Node | Way | Relation]

List of the elements related to this relation, including the relation itself.

Note

In reality this object only contains a list of elements, but to make it easier to use, it populates itself with the contents of the relation itself (which is always one of the items in the list of elements)

outer_geometry()

Tries to construct the outer geometry of the relation

Assuming that the relation has ways with the role "outer", the function tries to construct a MultiPolygon from those ways. The function does not assume that the ways are sorted properly.

Returns:

Type Description
MultiPolygon

A MultiPolygon representing the outer geometry of the relation

Member

Bases: BaseModel

Represents a membership in a relation

Attributes:

Name Type Description
type str

The type of the element (node, way, or relation)

ref int

The ID of the element

role str

The role of the element in the relation