fishnet
create_fishnet(*, bounds, res)
Generate a fishnet of polygons from bounds.
The function generates a grid of polygons within the specified bounds, where each
cell has dimensions defined by res. If the resolution does not perfectly divide
the bounds' dimensions (i.e., if res is not a factor of (xmax - xmin) or
(ymax - ymin)), the grid is still generated such that it fully covers the bounds.
This can result in cells that extend beyond the specified bounds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bounds
|
tuple[float, float, float, float]
|
(xmin, ymin, xmax, ymax) |
required |
res
|
tuple[float, float] | float
|
Resolution as |
required |
Returns:
| Type | Description |
|---|---|
GeometryArray
|
Shapely Polygons. |
Source code in src/rastr/gis/fishnet.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
create_point_grid(*, bounds, cell_size)
Create a regular grid of point coordinates for raster centers.
This function replicates the original grid generation logic that uses np.arange to ensure compatibility with existing code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bounds
|
tuple[float, float, float, float]
|
(xmin, ymin, xmax, ymax) bounding box. |
required |
cell_size
|
tuple[float, float] | float
|
Size of each grid cell as (width, height) or a single value for square cells. |
required |
Returns:
| Type | Description |
|---|---|
tuple[NDArray, NDArray]
|
Tuple of (x_coords, y_coords) meshgrids for raster cell centers. |
Source code in src/rastr/gis/fishnet.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
get_point_grid_shape(*, bounds, cell_size)
Calculate the shape of the point grid based on bounds and cell size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bounds
|
tuple[float, float, float, float] | ArrayLike
|
(xmin, ymin, xmax, ymax) bounding box. |
required |
cell_size
|
tuple[float, float] | float
|
Size of each grid cell as (width, height) or a single value for square cells. |
required |
Source code in src/rastr/gis/fishnet.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |