3

I am trying to convert thermal image data from a CSV format into a TIF. The FLIR software outputs the thermal image data as a .csv file which is formatted as below:

33.5,32.3,31.0,30.3,30.5,29.9,29.9,28.9,28.5,28.3,27.8,27.4,27.4,27.5,27.5,27.5,27.4,27.4,27.5,27.6,27.4,27.6,27.2,27.5,27.4,27.1,27.1,26.9,26.7,26.7,26.8,26.5,26.2,26.4,26.1,25.5,25.5,24.8,23.9,23.3,23.0,22.8,23.4,23.6,23.6,23.9,25.4,27.1,28.7,30.1,31.8,34.2,37.2,38.8,40.2,40.3,40.9,41.9,42.6,41.0,36.7,34.5,32.6,31.2,31.0,30.6,29.5,28.9,28.6,28.0,28.5,28.7,28.2,28.3,28.3,28.3,27.6,28.0,27.4,26.9,27.2,27.1,27.4,27.4,27.4,26.9,26.8,26.8,27.2,27.6,27.8,28.2,28.3,28.3,28.2,27.8,28.2,28.0,27.9,27.8,27.8,27.9,27.8,28.0,28.3,28.2,28.2,28.3,28.2,28.2,28.3,28.3,28.0,28.2,28.6,28.5,28.3,28.3,28.9,29.0,28.9,29.4,29.1,28.7,28.6,28.5,28.2,28.5,28.3,28.6,28.6,28.6,28.6,28.2,28.2,28.5,28.6,29.1,29.5,29.1,29.1,28.7,28.3,28.3,28.2,28.2,27.9,27.8,28.0,28.2,28.3,27.9,27.9,27.4,27.4,27.4,26.5,25.9,25.5,25.4,25.8,26.1,27.1,27.8,29.0,31.1,32.9,33.9,35.0,36.4,38.8,40.5,41.3,41.3,40.5,39.6,37.2,33.9,31.9,31.2,30.5,30.2,30.2,31.0,31.6,32.3,32.3,31.5,30.7,29.9,29.5,29.4,29.0,28.9,28.9,29.0,28.6,28.5,29.0,29.4,29.4,29.0,28.3,28.2,27.8,27.6,28.3,29.1,30.1,31.2,32.6,33.9,35.8,38.0,39.1,39.9,39.4,38.2,36.5,34.5,33.1,32.6,32.0,32.1,31.4,30.6,30.2,29.4,29.1,29.0,29.1,29.5,29.7,29.7,29.4,29.1,28.6,28.2,27.8,27.8,27.9,28.2,28.7,29.1,29.1,28.7,28.3,28.3,28.2,28.2,28.2,28.2,28.6,28.7,28.2,27.9,27.8,28.2,28.7,29.0,28.7,28.6,28.3,28.2,28.2,28.6,28.7,29.0,29.7,29.8,29.9,29.4,28.6,28.3,28.3,28.2,28.2,28.2,28.5,28.3,27.9,27.6,28.0,28.2,28.0,27.9,28.0,28.3,28.2,28.3,28.2,28.0,28.0,28.2,28.6,28.3,28.6,28.6,28.6,28.6,28.6,28.5,28.3,28.5,28.6,28.7,28.6,28.5,28.5,28.6,28.6,29.0,29.0,28.7,28.6,27.9,27.6,27.4,27.1,27.2,26.9,27.2,28.0,30.1,33.1,35.7,36.8,38.0,40.0,40.7,40.5,39.7,39.7,40.2,40.9,42.0,42.7,43.3,42.6,42.6,42.6,42.2,42.3,42.9,43.2,42.5,39.9,36.6,36.4,38.0,39.3,40.3,39.9,38.8,37.2,36.1,35.7,36.5,38.0,39.6,40.7,41.0,41.3,41.0,40.7,40.7,40.6,41.0,41.0,40.5,40.7,40.6,40.0,39.4,39.4,40.3,41.2,41.7,41.0,40.6,40.7,41.0,41.7,42.9,43.0,42.1,41.0,40.5,40.5,41.6,42.0,42.3,42.9,42.0,40.9,40.3,39.6,39.6,40.2,40.3,40.5,41.3,41.9,41.3,40.8,41.7,42.3,41.1,39.9,39.6,39.6,39.5,40.2,40.8,40.9,40.5,41.1,42.3,42.9,43.9,44.1,43.9,43.7,43.3,42.9,42.7,43.6,43.4,41.7,40.1,39.3,39.3,39.9,40.5,41.3,42.1,42.0,42.6,43.0,42.9,42.5,41.9,41.7,42.7,42.7,42.3,41.8,41.2,41.5,42.3,42.5,43.1,43.5,43.2,43.2,42.8,43.3,44.2,44.9,45.0,43.7,43.5,43.6,43.6,43.5,44.5,45.8,45.5,45.8,45.8,45.5,45.6,45.9,45.9,45.8,45.7,46.6,47.1,47.6,48.0,47.0,44.8,43.4,43.6,44.1,45.1,45.4,44.7,43.8,40.8,35.9,33.1,32.3,31.5,31.0,30.6,28.7,27.4,27.1,27.1,26.9,26.9,26.7,26.7,26.8,27.5,28.2,29.8,31.8,30.6,29.0,27.4,27.1,26.8,27.1,27.2,27.1,26.7,26.8,26.8,26.7,26.5,26.5,26.2,26.4,26.7,26.5,26.5,26.5,26.1,25.9,25.9,25.9,25.9,25.9,25.9,26.1,26.8,27.2,27.2,27.2,26.9,27.1,26.7,26.5,26.1,25.9,26.1,25.9,26.2,26.1,26.2,26.7,26.5,26.4,26.1,26.7,26.5,26.7,26.8,27.1,26.9,26.5,26.4,26.4,26.7,26.5,26.7,26.1,25.7,25.2,25.4,25.5,26.2,27.2,26.9,26.8,26.8,26.7,26.9,26.7,26.2,25.8,25.4,25.8,25.5,25.5,25.8,25.8,26.7,28.2,30.7,34.7,36.9,37.5,38.0,37.2,36.4,37.5,38.1,38.0,37.4,38.6,38.6,38.2,38.3,39.0,39.6,39.0,38.8,39.6,39.6,39.6,39.3,41.0,41.3,41.3,41.8,42.1,43.1,42.3,40.7,39.6,40.1,39.9,40.5,41.7,40.2,40.6,40.6,40.7,42.3,44.9,44.3,43.2,42.6,42.5,42.6,42.3,42.7 35.2,34.5,32.5,31.0,29.7,28.9,29.4,29.8,29.0,28.2,27.6,27.1,27.4,27.5,27.5,27.4,27.2,27.1,27.4,27.2,27.6,27.5,27.2,27.2,27.2,26.8,26.8,26.9,26.7,26.4,26.2,26.2,25.9,25.9,25.5,25.8,25.5,25.1,24.5,23.7,23.3,23.3,23.6,23.7,23.6,24.5,25.8,27.4,28.0,29.8,33.0,36.3,37.7,38.9,39.0,39.2,40.2,40.7,40.4,37.7,34.8,33.4,32.1,31.0,31.5,31.0,30.2,29.8,29.0,28.5,28.7,28.7,28.2,28.0,28.6,28.3,28.2,28.0,27.6,27.2,27.2,27.1,27.1,27.2,27.1,27.2,26.7,27.1,27.4,28.0,27.8,28.2,28.3,28.3,28.0,28.0,28.3,28.0,27.6,27.4,27.4,27.8,28.0,28.2,28.0,28.0,28.0,28.5,28.3,28.3,28.2,28.0,27.8,28.0,28.3,28.3,28.2,28.5,28.6,28.6,29.0,29.5,29.0,28.9,29.0,28.6,28.3,28.5,28.0,28.3,28.7,28.7,28.5,28.2,28.3,28.2,28.6,29.0,29.1,29.1,28.9,28.6,28.7,28.9,28.5,28.3,28.0,27.6,27.6,27.8,28.0,27.8,27.6,27.4,27.5,27.1,26.7,26.1,25.4,25.5,26.2,27.4,28.0,28.7,29.8,31.2,32.3,32.9,34.8,37.1,39.2,40.9,41.3,41.3,41.6,40.5,38.3,34.7,32.9,32.0,31.6,31.2,30.7,31.0,31.4,32.3,32.5,32.0,31.1,30.7,30.3,29.8,29.0,28.7,28.5,28.6,28.6,28.7,29.1,29.9,29.9,29.8,28.9,28.5,28.2,28.3,28.9,29.7,30.5,31.9,33.1,34.7,36.3,38.0,39.2,39.9,39.6,38.5,36.6,34.4,33.1,32.0,31.4,31.5,32.0,31.9,30.7,30.3,29.9,29.8,29.7,29.8,30.2,30.2,29.9,29.1,28.7,28.6,28.3,27.9,27.9,28.6,29.0,29.5,29.5,29.5,29.1,28.6,28.0,28.2,28.0,28.2,28.3,28.6,28.3,28.0,28.0,28.2,29.0,29.1,29.1,29.1,28.9,28.3,28.5,28.6,28.9,29.0,29.9,30.3,30.1,29.8,29.5,29.4,28.7,28.3,28.3,28.3,28.6,28.6,28.2,27.9,27.8,27.8,28.0,27.8,27.9,28.3,28.3,28.3,28.2,28.0,28.0,28.3,28.0,28.0,28.0,28.3,28.7,28.6,28.6,28.6,28.5,28.6,29.0,28.7,28.3,28.3,28.2,28.3,28.3,28.7,29.1,28.7,28.5,28.0,28.0,27.9,27.6,26.8,26.7,26.8,27.6,30.5,34.1,36.4,37.7,37.9,39.1,40.2,40.8,40.7,40.7,41.2,41.7,42.6,43.4,43.5,42.6,42.1,42.0,42.0,42.5,42.8,42.3,41.3,39.1,35.4,33.4,34.0,36.3,38.2,39.2,39.2,38.8,38.0,37.3,37.2,38.5,39.9,40.5,40.7,40.7,40.5,40.2,40.3,40.3,40.5,40.7,40.3,40.3,40.1,40.1,40.2,40.5,40.9,41.1,41.3,40.8,40.5,40.3,40.8,41.3,42.3,42.9,42.1,40.8,40.7,41.3,42.2,42.2,42.3,42.7,42.2,41.2,40.5,40.4,40.3,40.5,40.4,40.4,41.1,41.9,41.3,40.7,41.5,42.1,41.6,40.5,39.3,39.4,39.6,40.0,40.2,40.9,41.0,41.1,41.7,42.9,43.3,43.4,43.3,43.3,43.1,42.9,43.6,44.1,43.1,41.0,39.6,39.2,39.1,40.3,41.3,41.8,42.0,42.1,42.8,43.6,43.4,43.1,42.5,41.8,42.6,42.9,42.3,41.7,41.5,41.3,41.7,42.1,42.4,42.9,42.6,42.7,42.8,43.2,43.9,43.9,44.1,44.2,43.9,44.2,44.6,44.5,44.7,45.2,45.2,46.4,46.9,45.9,45.4,46.0,45.8,45.1,45.6,46.0,46.4,47.0,47.8,47.4,45.6,44.0,44.0,44.6,44.6,45.0,44.2,42.9,40.9,36.4,33.9,32.9,32.9,31.9,30.3,29.5,27.6,27.2,27.1,26.8,26.7,26.7,26.4,26.8,27.1,27.6,28.3,29.0,28.3,27.8,27.1,26.8,26.8,27.4,27.1,27.1,27.1,26.9,27.1,26.7,26.4,26.5,26.5,26.1,26.2,26.7,26.7,26.7,26.1,26.1,25.8,25.9,25.9,25.9,26.1,26.5,26.9,27.1,27.1,27.1,26.5,26.7,26.7,26.2,26.1,25.7,25.7,25.9,25.9,26.1,26.1,26.2,26.2,26.1,26.1,26.7,26.4,26.4,26.2,26.7,26.8,26.4,26.4,26.2,26.2,26.5,26.5,26.1,25.9,25.4,25.4,25.7,26.1,26.8,27.4,27.2,27.1,26.5,26.8,26.9,26.2,25.8,25.5,25.8,25.4,25.1,25.5,25.9,26.7,28.0,30.5,33.9,36.7,37.4,37.4,36.9,36.9,37.4,37.4,38.0,38.1,38.4,38.5,38.4,38.8,39.3,40.0,39.1,38.5,39.3,39.9,40.2,39.6,41.1,41.7,41.3,42.0,42.0,43.0,43.0,41.3,39.1,39.1,39.2,41.0,41.2,40.7,41.3,41.3,40.8,41.5,44.0,44.7,44.1,43.1,42.0,41.7,42.4,42.3

This is a very small section of the data to illustrate the formatting - Each row is composed of comma-separated values, with each row separated by a return. When opened with Excel and using conditional formatting, it can be visualised as each cell being a single pixel making up the image (which is 640 values/pixels by 512 values/pixels.

enter image description here

I need to convert this csv data into TIFs, but all the solutions I have found require column headers, such as x/y or lat/long which this data is missing. Does anyone know how I can achieve this?

2
  • 1
    I don't believe there are any coordinates (except for pixel position in the image grid) so this is probably not a GIS topic at all. A little python script should be fairly easy to do: ask Stackexchange, find examples or ask an LLM (gives 8 lines as a sample code).
    – Kasper
    Commented Dec 2 at 14:25
  • 2
    Read into a numpy array, save as an image
    – Bera
    Commented Dec 2 at 14:35

1 Answer 1

4

I think that the numpy route that @Bera suggested is better, but you can do what you want also with a text editor and gdal_translate.

First, find out how many rows and columns you have in the data and have a look at how ESRI AsciiGrid files are written https://github.com/OSGeo/gdal/blob/master/autotest/gdrivers/data/aaigrid/nodata_float.asc

Add header lines at the beginning of the text file with these values:

ncols        what-you-have-in-data
nrows        what-you-have-in-data
xllcorner    0
yllcorner    0
cellsize     1

Change the commas between the cell values into spaces. The linefeeds can stay as they are. These both small test files seem to work in the same way.

asciitest1.asc
==============
ncols        5
nrows        2
xllcorner    0
yllcorner    0
cellsize     1
1 2 3 4,5
6 7 8 9 10

asciitest2.asc
==============
ncols        5
nrows        2
xllcorner    0
yllcorner    0
cellsize     1
1 2 3 4 5 6 7 8 9 10

Test with gdalinfo:

gdalinfo asciitest.asc
Driver: AAIGrid/Arc/Info ASCII Grid
Files: asciitest.asc
Size is 5, 2
Origin = (0.000000000000000,2.000000000000000)
Pixel Size = (1.000000000000000,-1.000000000000000)
Corner Coordinates:
Upper Left  (   0.0000000,   2.0000000)
Lower Left  (   0.0000000,   0.0000000)
Upper Right (   5.0000000,   2.0000000)
Lower Right (   5.0000000,   0.0000000)
Center      (   2.5000000,   1.0000000)
Band 1 Block=5x1 Type=Float32, ColorInterp=Undefined

Convert into TIFF:

gdal_translate asciitest2.asc asciitest2.tif
Input file size is 5, 2
0...10...20...30...40...50...60...70...80...90...100 - done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.