Wie füge ich mit GDAL eine Farbtabelle zu einem Einband-Tiff hinzu?


11

Ich habe eine 1-Band-GeoTIFF-Datei. Die Farbinterpretation für Band ist grau. Ich möchte eine Farbtabelle, um meine Col.tiffzu Col.jpegoder zu transformieren Col.png.

Ich habe versucht, eine Farbtabelle über eine .vrt:

gdal_translate -of VRT  Col.tiff Col.vrt

Fügen Sie dann die .vrt hinzu:

<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>

Und noch einmal übersetzen:

gdal_translate Col.vrt Col.tiff

Aber es antwortete:

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.

Wie kann ich es tun?

Zur Information gibt es gdalinfo für die 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

Welche Max / Min-Werte hat Ihr TIF? Es ist Float64. Wie sollte dieser Dezimalwert den ganzzahligen Werten für eine Farbpalette entsprechen?
— AndreJ

Der Fehler besagt, dass die Ausgabe vom Typ Byte oder UInt16 sein muss. Vielleicht sollten Sie dem Befehl gdal_translate "-ot UInt16" hinzufügen.
— user30184

Danke, es funktioniert jetzt, ich muss nur die guten Farben finden :)
— Faquarl

@AndreJoost Was ich getan habe, ist, Max / Min-Werte zu nehmen und sie auf 255 Klassen aufzuteilen. Dann habe ich für jeden Wert eine Farbe eingefügt.
— Faquarl

Schließlich habe ich ein Python-Skript erstellt, um ein neues Tiff mit denselben Informationen zu erstellen, außer dass es 4 Bands (rgba) gibt
— Faquarl

Antworten:


5

Mit gdal können Sie ein Bild basierend auf gdal_dem ( color_relief ) ausmalen.

Die Syntax der Farbkonfigurationsdatei leitet sich von der vom Dienstprogramm GRASS r.colors unterstützten ab . ESRI HDR-Farbtabellendateien (.clr) stimmen ebenfalls mit dieser Syntax überein. Die Alpha-Komponente und die Unterstützung von Tabulatoren und Kommas als Trennzeichen sind GDAL-spezifische Erweiterungen

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

Siehe auch mein erweitertes Beispiel hier: gis.stackexchange.com/questions/130199/…
— AndreJ

Link direkt zu @ AndreJs Antwort: gis.stackexchange.com/a/132690/49134
— Tom Saleeba

Ja, danke, diese Fragen für 2015 sollten als doppelt markiert werden, aber die Antwort von AndreJ ist detaillierter als meine.
— Radouxju
Durch die Nutzung unserer Website bestätigen Sie, dass Sie unsere Cookie-Richtlinie und Datenschutzrichtlinie gelesen und verstanden haben.
Licensed under cc by-sa 3.0 with attribution required.