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

Chaitanya kumar CH chaitanya.ch at gmail.com
Mon Jul 25 00:18:14 EDT 2011


Stefan,

You can convert the integer codes to float values using a VRT file[1] for
each gif file.
Create a VRT file with the ColorTable element. Add the SimpleSource to point
to your gif and the SourceBand element as 3 to point to B band.

Once you create a VRT file for the GIF, you can use it like any other raster
file. GDAL interprets the elements in it and applies the conversions
internally. Use it with gdal_translate or gdalwarp (if you want to warp it
to a new coordinate system) to create an ASCII Grid file.

[1]: http://www.gdal.org/gdal_vrttut.html

On Mon, Jul 25, 2011 at 12:39 AM, Stefan Keller <sfkeller at gmail.com> wrote:

> 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.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>



-- 
Best regards,
Chaitanya kumar CH.

+91-9494447584
17.2416N 80.1426E
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20110725/38417678/attachment.html


More information about the gdal-dev mailing list