[gdal-dev] How to convert a GIF (being a grid with value in channel B from RGB) to XYZ?

Stefan Keller sfkeller at gmail.com
Sun Jul 24 15:09:20 EDT 2011


I have a raster/grid file transformation and conversion question:

The input are hunddrets of GIF files which in fact are a grid about
rainfall observations. The files have 8 BitsPerPixel (0..255). The B
channel (integer value) from RGB obviously represents the
precipitation intensity in [mm/h] according to a lookup table (0=>0,
1=>0.2, 2=>0.32, 3=>0.5, 4=>0.8, 5=1.3, 6=>2, 7=>5, 8=>8 9=>13 10=>20,
11=>32, 12=>50, 13=>50, 14=>80, 15=>130).

The GIF size (= grid size) is 400x400 pixel with a cell size of 1000m.
The following is known about the geolocation (Switzerland,
EPSG:21781/CH1903): xmin: 481000, ymin: 38000 and xmax: 881000, ymax:
438000.

The target format is ASCII Gridded (XYZ)? or Arc/Info ASCII Grid
(AAIGrid), with e.g. the following on each line: "481000 38000 0.32",
meaning the transformed coordinates x and y and the float value (as
indicated above in the lookup table).

I know OGR but I'm new to GDAL: How would you accomplish this task?

Transforming with gdal_transform then converting with gdal_translate ?
Or do I have to write something myself (perhaps based on gdal2xyz.py)?

-S.


More information about the gdal-dev mailing list