cartagen.partition_networks

cartagen.partition_networks#

partition_networks(objects, *networks)#

Partition objects using one or multiple networks.

Create the faces from one or multiple networks and partition the provided objects into groups. Objects are grouped when their centroid intersects the same network face. This algorithm rely on a STRtree indexing solution.

Parameters:
  • objects (GeoDataFrame of Geometry) – The objects to partition. Their centroids are used to assign them to a network face.

  • *networks (GeoDataFrame of LineString) – The networks used to partition the objects.

Returns:

partition (tuple) – A tuple containing two elements :

  1. A list of lists of index ordered by the network faces

  2. A list of the geometry of the network faces

See also

network_faces

Calculates the faces of one or multiple networks.

partition_grid

Partition objects using a grid of a given shape.

Examples

>>> points = GeoDataFrame(geometry=[ Point(2, 1), Point(4, 1) ])
>>> network = GeoDataFrame(geometry=[ LineString([(0, 0), (3, 0), (3, 2), (6, 2)]) ])
>>> partition_networks(points, network)
([[1], [0]], [<POLYGON ((3 2, 6 2, 3 0, 3 2))>, <POLYGON ((3 2, 3 0, 0 0, 3 2))>])

(Source code)

../_images/partition_networks.png