Answers for "resample rasterio python"

0

resample rasterio python

import rasterio
from rasterio.enums import Resampling

upscale_factor = 2

with rasterio.open('my_raster.tif') as dataset:

    # resample data to target shape
    data_s = dataset.read(
        out_shape=(
            dataset.count,
            int(dataset.width * upscale_factor),
            int(dataset.height * upscale_factor)
        ),
        resampling=Resampling.bilinear
    )

    # scale image transform
    transform = dataset.transform * dataset.transform.scale(
        (dataset.width / data.shape[-2]),
        (dataset.height / data.shape[-1])
    )
Posted by: Guest on March-20-2020

Python Answers by Framework

Browse Popular Code Answers by Language