tiling.const_size¶
Class provides constant size tile parameters (offset, extent) to extract data from image.
Generated tile extents can overlap, do not includes nodata paddings. For example, tiling can look like this:
tile 0 tile 2 tile 4
|<------>| |<------>| |<------>|
tile 1 tile 3 tile 5
|<------>| |<------>| |<------>|
|<------------------------------------>|
| IMAGE |
| |
Basic usage:
from tiling import ConstSizeTiles
tiles = ConstSizeTiles(image_size=(500, 500), tile_size=(256, 256), min_overlapping=100)
print("Number of tiles: %i" % len(tiles))
for x, y, width, height in tiles:
data = read_data(x, y, width, height, tiles.tile_size[0], tiles.tile_size[0])
print("data.shape: {}".format(data.shape))
-
class
tiling.const_size.
ConstSizeTiles
(image_size, tile_size, min_overlapping=0, scale=1.0)[source]¶ Class provides constant size tile parameters (offset, extent) to extract data from image. Generated tile extents can overlap and do not includes nodata paddings.
Examples
from tiling import ConstSizeTiles tiles = ConstSizeTiles(image_size=(500, 500), tile_size=(256, 256), min_overlapping=15, scale=1.0) print("Number of tiles: %i" % len(tiles)) for extent, out_size in tiles: x, y, width, height = extent data = read_data(x, y, width, height, out_width=out_size[0], out_height=out_size[1]) print("data.shape: {}".format(data.shape))
Parameters: - image_size (list/tuple of int) – input image size in pixels (width, height)
- tile_size (int or list/tuple of int) – output tile size in pixels (width, height)
- min_overlapping (int) – minimal overlapping in pixels between tiles.
- scale (float) – Scaling applied to the input image parameters before extracting tile’s extent
-
next
()¶ Method to get next tile
Returns: tile data (ndarray), tile extent (list) in the original image, in pixels