The closest thing you can do without doing any coding is to use the
gdal_contour utility[1] to create a vector file and then use gdal_rasterize
[2] to burn them back to a raster. If you use appropriate options, all your
pixels will be clamped to the discrete levels used in gdal_contour. It's
straight forward to apply a color table to that.

If you want to do this using a script, refer to the gdal API tutorial[3].
You'll have to do the classification while you read and write the pixels
using GDALRasterIO(). You can set the color table too.

Note that there may be some differences along the edges of classified pixels
between these two methods. The lines generated by gdal_contour may go
through the area of a pixel and could change the burn value.

[1]: http://www.gdal.org/gdal_contour.html
[2]: http://www.gdal.org/gdal_rasterize.html
[3]: http://www.gdal.org/gdal_tutorial.html

On Fri, Jul 29, 2011 at 12:05 AM, Stephen Crawford <src...@psu.edu> wrote:

> **
> Thanks for the reply.  I had looked at these before, and then looked again
> after your note, but I just don't understand how I map the climate variable
> values to different colors in the palette, along the lines of:
>
> tmax < 30            |  color1
> 30 < tmax < 50   | color2
> tmax > 50            | color3
>
> Thanks,
> Steve
>
>
> On 7/27/2011 1:01 AM, Chaitanya kumar CH wrote:
>
> Sorry, here are the links.
>
> [1]: http://www.gdal.org/rgb2pct.html
>
> [2]: http://www.gdal.org/gdal_vrttut.html
> [3]: http://www.gdal.org/formats_list.html
>
> On Wed, Jul 27, 2011 at 10:30 AM, Chaitanya kumar CH <chaitanya.ch@
> gmail.com> wrote:
>
>> Stephen,
>>
>> The docs for rgb2pct.py script [1] has an example that shows how to
>> convert to a paletted image using hand made VRT file.
>> You can use the "-of PNG" option to set the destination format as png and
>> the -pct option with your VRT file.
>>
>>
>> On Wed, Jul 27, 2011 at 2:42 AM, Stephen Crawford <src...@psu.edu> wrote:
>>
>>> Hi All,
>>>
>>> I have 60 or so asciiGrids of climate data that I would like to tun into
>>> PNGs, with the climate values classified by color.  I would like to script
>>> this process using Python.  Is there a way to do this with GDAL?  Or if not,
>>> is there any other open source way to do this?
>>>
>>> Thanks,
>>> Steve
>>>
>>>
>>> _______________________________________________
>>> gdal-dev mailing list
>>> gdal-dev@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
>
>
> --
> Stephen Crawford
> Center for Environmental Informatics
> The Pennsylvania State universitysrc...@psu.edu
> 814.865.9905
>
>


-- 
Best regards,
Chaitanya kumar CH.

+91-9494447584
17.2416N 80.1426E
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to