Skip to content

Latest commit

 

History

History
54 lines (39 loc) · 1.48 KB

readme.md

File metadata and controls

54 lines (39 loc) · 1.48 KB

GDAL boots

Python friendly wrapper over GDAL

boots

"When you see someone putting on his Big Boots, you can be pretty sure that an Adventure is going to happen."

A. A. Milne

WARNING

This is early implementation of library, use it for you own risk.

Example

import json
import affine
import numpy as np
from gdal_boots import RasterDataset, GeoInfo, JP2OpenJPEG, GTiff

minsk_polygon = json.load(open('./tests/fixtures/minsk-polygon.geojson'))

img = np.random.randint(
    0, 255,
    size=(1098, 1098),
    dtype=np.uint8)

geoinfo = GeoInfo(
    epsg=32635,
    transform=(
        affine.Affine(10.0, 0.0, 499980.0, 0.0, -10.0, 6000000.0) *
        affine.Affine.scale(10, 10)
    )
)
with RasterDataset.create(img.shape, img.dtype, geoinfo) as ds:
    ds[:,:] = img
    ds[100:350, 100:350] = 128
    ds.to_file('tile.jp2', JP2OpenJPEG(quality=50))

    cropped_ds = ds.crop_by_geometry(minsk_polygon)
    cropped_ds.to_file('minsk.tif', GTiff(tiled=True))

usefull links: