[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
Tue Jul 26 04:23:11 EDT 2011


Hi Chaitanya

Thanks again for the hint. I have now to experiment with GeoTransform.
I first let generate a valid VRT to start doing a "% gdal_translate
-of VRT myinputfile.gif myinputfile.vrt". But I still have some
issues:

1. I'm stuck on where to put the geofererencing information (being
lower/left target coord in EPSG:21781 and pixel size 1000m). Are there
tools which calculate "six value affine geotransformation values"
(given lower/left target coord and pixel size 1000m)?

2. I'm confused what's the difference between GeoTransform and
offset/scale subtags in VRTRasterBand even after reading the VRT
tutorial (http://www.gdal.org/gdal_vrttut.html ).

3. Is there a way to process 600 input files without generating 600
VRT-files (one should have a placeholder in subtag SourceFilename
(under SimpleSource) which takes over the input parameters from the
gdal_translate shell command.)?

Yours, S.


2011/7/25 Chaitanya kumar CH <chaitanya.ch at gmail.com>:
> If the transformation is just shifting and scaling you can set the
> GeoTransform element in the VRT file.
> You can scale the pixel values using the Offset and Scale elements.
>
> On Mon, Jul 25, 2011 at 5:24 PM, Stefan Keller <sfkeller at gmail.com> wrote:
>>
>> Hi Chaitanya kumar
>>
>> Many thanks for the hints. I know VRT from OGR but was not sure if this
>> works here too.
>>
>> What I'm still wondering is, how to accomplish the transformation.
>> It's rather a coord. translation process not comparable to warping:
>>
>> > 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.
>>
>> So I'd like to do some shifting and scaling before XY-coordinates are
>> output (Z coming from the Colortable).
>>
>> Yours, S.
>>
>>
>> 2011/7/25 Chaitanya kumar CH <chaitanya.ch at gmail.com>:
>> > 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
>> >
>
>
>
> --
> Best regards,
> Chaitanya kumar CH.
>
> +91-9494447584
> 17.2416N 80.1426E
>


More information about the gdal-dev mailing list