vectorize
get_polygons(binary_mask, min_area=25.5, polygon_buffer=0, tolerance=1.0, transform=None)
¶
Vectorize the polygons of the provided binary_mask.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
binary_mask
|
Union[ndarray, GeoData]
|
(H, W) binary mask to rasterise |
required |
min_area
|
float
|
polygons with pixel area lower than this will be filtered |
25.5
|
polygon_buffer
|
int
|
buffering of the polygons |
0
|
tolerance
|
float
|
to simplify the polygons |
1.0
|
transform
|
Optional[Affine]
|
affine transformation of the binary_water_mask raster. It will be used only if binary mask is numpy array. |
None
|
Returns:
Type | Description |
---|---|
List[Polygon]
|
list of vectorized polygons |
Source code in georeader/vectorize.py
9 10 11 12 13 14 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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
transform_polygon(polygon, transform, relative=False, shape_raster=None)
¶
Transforms a polygon from pixel coordinates to the coordinates specified by the affine transform
Parameters:
Name | Type | Description | Default |
---|---|---|---|
polygon
|
Union[Polygon, MultiPolygon]
|
polygon to transform |
required |
transform
|
Affine
|
Affine transformation |
required |
relative
|
bool
|
if True, the polygon is transformed to relative coordinates (from 0 to 1) |
False
|
shape_raster
|
Optional[Tuple[int, int]]
|
shape of the raster to which the polygon belongs. It is used only if relative is True |
None
|
Returns:
Type | Description |
---|---|
Union[Polygon, MultiPolygon]
|
polygon with coordinates transformed by the affine transformation |
Source code in georeader/vectorize.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|