Reading and manipulation of geographical images. Based on GDAL
pip install numpy click
sudo apt-get install libgdal-dev
pip install gdal
pip install numpy
brew install gdal2
pip install gdal
pip install git+https://github.com/vfdev-5/TinyGeoImageUtils.git
GeoImage
for reading geographical imagesGeoImageTiler
for tiled reading geographical images
import numpy as np
import matplotlib.pyplot as plt
from gimg import GeoImage
gimg = GeoImage("path/to/image/file")
data = gimg.get_data([0, 0, 500, 500])
print(data.shape, data.type)
plt.imshow(data[:, :, 0])
plt.show()
and
import numpy as np
import matplotlib.pyplot as plt
from gimg import GeoImage
from gimg import GeoImageTilerConstSize
gimg = GeoImage("path/to/image/file")
tiles = GeoImageTilerConstSize(gimg, tile_size=(512, 512), min_overlapping=128)
for tile, x, y in tiles:
print(tile.shape, tile.type, x, y)
See other examples:
Application to write tiles from input single image or a folder of images.
Generate tiles of constant size with overlapping.
> tile_generator const_size --help
Usage: tile_generator const_size [OPTIONS] INPUT_DIR_OR_FILE OUTPUT_DIR
TILE_SIZE_IN_PIXELS MIN_OVERLAPPING_IN_PIXELS
Options:
--extensions TEXT String of file extensions to select (if input is a
directory), e.g. 'jpg,png,tif'
--output_extension TEXT Output tile file extension
--n_workers INTEGER Number of workers in the processing pool
[default=4]
-q, --quiet Disable verbose mode
--help Show this message and exit.
For example,
> mkdir examples/tiles
> tile_generator const_size --extensions="jpg,png" examples/dog.jpg examples/tiles 256 20