Skip to content

Some tools to quickly read geographical images and iterate over the image content by tiles

License

Notifications You must be signed in to change notification settings

vfdev-5/TinyGeoImageUtils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tiny Geographical Image Utils

Build Status Coverage Status

Reading and manipulation of geographical images. Based on GDAL

Installation:

Dependencies:

Linux

pip install numpy click
sudo apt-get install libgdal-dev
pip install gdal

MacOSX

pip install numpy
brew install gdal2
pip install gdal

Repository

pip install git+https://github.com/vfdev-5/TinyGeoImageUtils.git

Basic tools:

Python API

  • GeoImage for reading geographical images
  • GeoImageTiler for tiled reading geographical images

Usage:

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:

CLI

tile_generator

Application to write tiles from input single image or a folder of images.

tiles of constant size

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

About

Some tools to quickly read geographical images and iterate over the image content by tiles

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages