Come aggiungere una tabella di colori a un tiff a una banda usando GDAL?


11

Ho un file GeoTIFF a 1 banda. L'interpretazione del colore per la banda è grigia. Voglio una tabella di colori per trasformare il mio Col.tiffin Col.jpego Col.png.

Ho provato a mettere una tabella di colori in questo tiff tramite un .vrt:

gdal_translate -of VRT  Col.tiff Col.vrt

quindi aggiungendo in .vrt:

<ColorInterp>Palette</ColorInterp>
<ColorTable>
   <Entry c1="0" c2="0" c3="255" c4="240"/>
   <Entry c1="0" c2="0" c3="254" c4="240"/>
   <Entry c1="0" c2="0" c3="253" c4="240"/>
   <Entry c1="0" c2="0" c3="252" c4="240"/>
</ColorTable>

E tradurre di nuovo:

gdal_translate Col.vrt Col.tiff

Ma ha risposto:

Warning 1: Unable to export color table to GeoTIFF file.  Color tables can only be written to 1 band or 2 bands Byte or UInt16 GeoTIFF files.

Come posso farlo?

Per informazioni, c'è gdalinfo per la band:

Band 1 Block=55x18 Type=Float64, ColorInterp=Gray
  Description = Something
  Metadata:
    GRIB_COMMENT=Something[p]
    GRIB_ELEMENT=TMP
    GRIB_FORECAST_SECONDS=0 sec
    GRIB_REF_TIME=1401926400 sec UTC
    GRIB_SHORT_NAME=SMTHG
    GRIB_UNIT=[p]
    GRIB_VALID_TIME=1401926400 sec UTC

Quali valori max / min ha il tuo tif? È Float64, quindi come dovrebbe corrispondere questo valore decimale ai valori interi per una tavolozza dei colori?
— AndreJ,

L'errore indica che l'output deve essere di tipo Byte o UInt16. Forse dovresti aggiungere "-ot UInt16" nel comando gdal_translate.
— user30184

Grazie, funziona ora, ho solo bisogno di trovare i bei colori :)
— Faquarl

@AndreJoost Quello che ho fatto è prendere i valori max / min e dividerli tra 255 classi. Quindi, per ogni valore, metto un colore.
— Faquarl,

Alla fine ho realizzato uno script Python per creare un nuovo tiff con le stesse informazioni, tranne per il fatto che ci sono 4 bande (rgba)
— Faquarl,

Risposte:


5

con gdal puoi colorare un'immagine in base a gdal_dem ( color_relief )

la sintassi del file di configurazione del colore è derivata da quella supportata dall'utilità GRASS r.colors . Anche i file della tabella dei colori HDR ESRI (.clr) corrispondono a quella sintassi. Il componente alfa e il supporto di tabulazione e virgola come separatori sono estensioni specifiche GDAL

aspect: aspect oriented grey colors
aspectcolr: aspect oriented rainbow colors
bcyr: blue through cyan through yellow to red
bgyr: blue through green through yellow to red
byg: blue through yellow to green
byr: blue through yellow to red
celsius: blue to red for degree Celsius temperature
corine: EU Corine land cover colors
curvature: for terrain curvatures (from v.surf.rst and r.slope.aspect)
differences: differences oriented colors
elevation: maps relative ranges of raster values to elevation color ramp
etopo2: colors for ETOPO2 worldwide bathymetry/topography
evi: enhanced vegetative index colors
gdd: accumulated growing degree days
grey: grey scale
grey.eq: histogram-equalized grey scale
grey.log: histogram logarithmic transformed grey scale
grey1.0: grey scale for raster values between 0.0-1.0
grey255: grey scale for raster values between 0-255
gyr: green through yellow to red
haxby: relative colors for bathymetry or topography
ndvi: Normalized Difference Vegetation Index colors
population: color table covering human population classification breaks
population_dens: color table covering human population density classification breaks
precipitation: precipitation color table (0..2000mm)
precipitation_monthly: precipitation color table (0..1000mm)
rainbow: rainbow color table
ramp: color ramp
random: random color table
rstcurv: terrain curvature (from r.resamp.rst)
rules: create new color table based on user-specified rules read from stdin
ryb: red through yellow to blue
ryg: red through yellow to green
sepia: yellowish-brown through to white
slope: r.slope.aspect-type slope colors for raster values 0-90
srtm: color palette for Shuttle Radar Topography Mission elevation
terrain: global elevation color table covering -11000 to +8850m
wave: color wave

Vedi anche il mio esempio esteso qui: gis.stackexchange.com/questions/130199/…
— AndreJ

link direttamente alla risposta di @ AndreJ: gis.stackexchange.com/a/132690/49134
— Tom Saleeba

sì, grazie, quelle domande del 2015 dovrebbero essere contrassegnate come duplicate ma la risposta di AndreJ è più dettagliata della mia.
— Radouxju,
Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.