[gdal-dev] palette file format doc ?

2024-03-20 Thread Michael Sumner via gdal-dev
Is the palette_file  .txt format documented?

https://gdal.org/programs/gdalattachpct.html

It's mentioned in a few utilities, and created by tests but I couldn't find
an existing example or a description (I guessed, incorrectly at first,
leaving out the index column). I take it that it is 0-255 range values, but
is index 0-based or 1? And, can index be *value* in any contexts?

index  red green blue 

If it's documented I'll link it in PRs. I see qml and qlr here:
https://docs.qgis.org/3.34/en/docs/user_manual/appendices/qgis_file_formats.html

Cheers, Mike


-- 
Michael Sumner
Software and Database Engineer
Australian Antarctic Division
Hobart, Australia
e-mail: mdsum...@gmail.com
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] palette file format doc ?

2024-03-20 Thread Even Rouault via gdal-dev

Michael,

Le 20/03/2024 à 21:38, Michael Sumner via gdal-dev a écrit :

Is the palette_file  .txt format documented?

https://gdal.org/programs/gdalattachpct.html

It's mentioned in a few utilities, and created by tests but I couldn't 
find an existing example or a description (I guessed, incorrectly at 
first, leaving out the index column). I


The initial attachpct.py script only worked with a GDAL raster as the 
source for the palette. The support for text formats, or qml, qlr seems 
to be a later addition by Idan Miara, and the best doc is probably the 
code: 
https://github.com/OSGeo/gdal/blob/master/swig/python/gdal-utils/osgeo_utils/auxiliary/color_palette.py 
. You may also have a look at autotest/pyscripts/test_gdal_utils.py 
which has tests for this color palette reading code. Looking a bit at 
it, I suspect the GDAL text format refered is the one actually used by 
gdaldem color-relief: 
https://gdal.org/programs/gdaldem.html#color-relief , which is itself 
derived from the one used by GRASS r.colors . But the Python code (only 
Python) and the one used by gdaldem (only C++) are different, so I 
wouldn't exclude there might be some differences.


| take it that it is 0-255 range values, but is index 0-based or 1?

0-based, as (unsigned) raster values are


And, can index be *value* in any contexts?


If you use a raster with a signed data type, that could be negative 
values (assuming I understand your question)


Even

--
http://www.spatialys.com
My software is free, but my time generally not.

___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] palette file format doc ?

2024-03-20 Thread Michael Sumner via gdal-dev
>
>
>
> > And, can index be *value* in any contexts?
>
> If you use a raster with a signed data type, that could be negative
> values (assuming I understand your question)
>
>

ah I see, arbitrary integer values map to a colour 0:(n-1) colours, match
the ordered n values in the raster - that is "value" in the way I was
thinking  ( I had in mind more general cases like interval ranges, but
that's  another level up)

I might be entirely messing up the concept ... will check my take by
experiment.

Cheers, Mike


-- 
Michael Sumner
Software and Database Engineer
Australian Antarctic Division
Hobart, Australia
e-mail: mdsum...@gmail.com
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] palette file format doc ?

2024-03-20 Thread Even Rouault via gdal-dev


Le 21/03/2024 à 01:43, Michael Sumner a écrit :




> And, can index be *value* in any contexts?

If you use a raster with a signed data type, that could be negative
values (assuming I understand your question)



ah I see, arbitrary integer values map to a colour 0:(n-1) colours, 
match the ordered n values in the raster - that is "value" in the way 
I was thinking  ( I had in mind more general cases like interval 
ranges, but that's  another level up)


I might be entirely messing up the concept ... will check my take by 
experiment.


It was wrong about negative values. As this script ultimately writes a 
GDALColorTable, you must use >=0 indices.



--
http://www.spatialys.com
My software is free, but my time generally not.
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev