def tile_from_polygon(self, tile_builder, polygon, mask=False):
"""Build a tile being the minimum bounding box around the passed polygon
Parameters
----------
tile_builder: TileBuilder
The builder for effectively building the tile
polygon: shapely.geometry.Polygon
The polygon of which the bounding tile should be returned
mask: boolean (optional, default: False)
True for applying the polygon as an alpha mask to the tile
Returns
-------
tile: Tile
The bounding tile
Raises
------
IndexError: if the offset is not inside the image
TileExtractionException: if the tile cannot be extracted
"""
offset, width, height = Image.polygon_box(polygon)
return self.tile(tile_builder, offset, width, height, polygon_mask=polygon if mask else None)
评论列表
文章目录