from geotile import GeoTile
import numpy as np
gt = GeoTile(r"path/to/raster.tif")
# generate tiles but save it only on the class
gt.generate_tiles(r'../data/test_tiles', save_tiles = False)
# normalize data
gt.normalize_tiles()
# convert nan values to zero
gt.convert_nan_to_zero()
From above code, the data will be stored in gt.tile_data with shape (num_sample, x, y, num_bands). Now you can run the prediction code and replace the tile_data as below,
prediction = model.predict(gt.tile_data)
# You can run intermediate steps such as thresholding, reshaping etc
# But you need to finally reshape it to (num_sample, x, y, num_bands) format
# after that, simply overwrite the tile_data in geotile
gt.tile_data = prediction
gt.save_tiles('/path/to/output/folder')
After saving the tiles, you can merge tiles by following code;
from geotile import mosaic
mosaic('/path/to/input/tiles', '/path/to/output/file.tif')
Now it can be done with following code,
From above code, the data will be stored in
gt.tile_data
with shape(num_sample, x, y, num_bands)
. Now you can run the prediction code and replace the tile_data as below,After saving the tiles, you can merge tiles by following code;