0 votes
in Python Imaging Library by
How to Change in altitude value after resizing .tif file

1 Answer

0 votes
by
Pillow isn't a geospatial library, I recommend looking at rasterio resampling

For example:

import rasterio

from rasterio.enums import Resampling

# Register GDAL format drivers and configuration options with a

# context manager.

with rasterio.Env():

    with rasterio.open('/path/to/input.tif') as dataset:

        data = dataset.read(1, out_shape=(1200, 1200), resampling=Resampling.bilinear)

        # scale image transform

        transform = dataset.transform * dataset.transform.scale(

            (dataset.height / data.shape[0]),  # rows

            (dataset.width / data.shape[1])  # cols

        )

        profile = dataset.profile

        profile.update(transform=transform, width=data.shape[1], height=data.shape[0])

    with rasterio.open('/path/to/output.tif', 'w', **profile) as dataset:

        dataset.write(data, 1)
...