1

I want to transform a csv file into a tiff image. Each single cell of the csv file contains a temperature value which should be transfered as the value for each individual pixel in the tiff image, similar to an rtiff.

So far I only managed to export the image as a tiff (black&white), but the pixel values don't correspond to the temperature values.

tir= read.csv(("record.csv"), sep = ",", header = FALSE, stringsAsFactors = TRUE)
tir_M= as.matrix(tir, rownames=TRUE, rownames.value=TRUE, stringsAsFactors = FALSE)
tir_M100= tir_M/100
writeTIFF(tir_M100, 'record.tif', reduce = TRUE)

How can I store the temperature values in the tiff?

Thanks for any suggestions

R_newbie
  • 11
  • 1

1 Answers1

1

This worked for me:

import csv
import numpy as np
from PIL import Image


def main():
    my_file = 'GIA.csv'
    image_array = np.genfromtxt(my_file, delimiter=',')
    my_image = Image.fromarray(image_array)  # https://stackoverflow.com/a/7572079/9044571
    my_image.save('GIA.tiff')


if __name__ == '__main__':
    main()

The values in GIA.csv were floats.