Страница 1 из 1

gis images

Добавлено: Сб, 16 декабря 2023, 12:00:14
dyvniy
First, I downloaded a test TIFF image from this page called a_image.tif. Then I opened with PIL like this:
>>> from PIL import Image
>>> im = Image.open('a_image.tif')
>>> im.show()
This showed the rainbow image. To convert to a numpy array, it's as simple as:
>>> import numpy
>>> imarray = numpy.array(im)
We can see that the size of the image and the shape of the array match up:
>>> imarray.shape
(44, 330)
>>> im.size
(330, 44)
And the array contains uint8 values:
>>> imarray
array([[ 0, 1, 2, ..., 244, 245, 246],
[ 0, 1, 2, ..., 244, 245, 246],
[ 0, 1, 2, ..., 244, 245, 246],
...,
[ 0, 1, 2, ..., 244, 245, 246],
[ 0, 1, 2, ..., 244, 245, 246],
[ 0, 1, 2, ..., 244, 245, 246]], dtype=uint8)
Once you're done modifying the array, you can turn it back into a PIL image like this:
>>> Image.fromarray(imarray)
<Image.Image image mode=L size=330x44 at 0x2786518>

Добавлено: Сб, 16 декабря 2023, 18:27:44
dyvniy
карта высот без деревьев, больше 400 гигов в сжатом виде.
https://data.bris.ac.uk/data/dataset/25wfy0f9ukoge2gs7a5mqpq2j7

Добавлено: Сб, 16 декабря 2023, 21:31:54
dyvniy