cartagen.partition_grid#
- partition_grid(objects, width, height=None, shape='square')#
Partition objects using a grid of a given shape.
This algorithm divides the extent of the provided objects using a regular grid of the specified shape and size and assign the objects to the cell they intersects.
- Parameters:
objects (
GeoDataFrame) – The objects to partition.width (
float) – Width of the grid.height (
float, optional) – Height of the grid. If set to None, the height equals the width.shape (
str, optional) – Shape of the grid cells, can be ‘square’, ‘diamond’, ‘hexagonal’.
- Returns:
partition (
tuple) – A tuple containing two elements :A list of lists of index ordered by the grid cells
A list of the geometry of the grid cells
See also
tessellateCreate a tessellation of cells of a given shape.
partition_quadtreePartition objects using a quadtree.
partition_networksPartition objects using one or multiple networks.
Examples
>>> points = gpd.GeoDataFrame(geometry=[ Point(2, 1), Point(4, 2) ]) >>> partition_grid(points, 1) ([[0], [1]], [<POLYGON ((2 1, 3 1, 3 2, 2 2, 2 1))>, <POLYGON ((3 1, 4 1, 4 2, 3 2, 3 1))>])