Bagaimana cara menambahkan tabel warna ke tiff satu band menggunakan GDAL?


11

Saya memiliki file GeoTIFF 1-band. Interpretasi warna untuk band adalah abu-abu. Saya ingin tabel warna untuk mengubah Col.tiffke Col.jpegatau Col.png.

Saya mencoba meletakkan tabel warna di tiff ini melalui .vrt:

gdal_translate -of VRT  Col.tiff Col.vrt

lalu tambahkan dalam .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>

Dan terjemahkan lagi:

gdal_translate Col.vrt Col.tiff

Tapi itu menjawab:

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.

Bagaimana saya bisa melakukannya?

Sebagai informasi, ada gdalinfo untuk 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

Nilai maks / min apa yang dimiliki tif Anda? Ini adalah Float64, jadi bagaimana seharusnya nilai desimal ini sesuai dengan nilai integer untuk palet warna?
— AndreJ

Kesalahan mengatakan bahwa output harus bertipe Byte atau UInt16. Mungkin Anda harus menambahkan "-ot UInt16" ke dalam perintah gdal_translate.
— user30184

Terima kasih, ini berfungsi sekarang, saya hanya perlu menemukan warna yang bagus :)
— Faquarl

@AndreJoost Apa yang saya lakukan adalah mengambil nilai max / min dan membaginya di antara 255 kelas. Lalu, untuk setiap nilai, saya beri warna.
— Faquarl

Akhirnya saya membuat skrip Python untuk membuat tiff baru dengan informasi yang sama kecuali ada 4bands (rgba)
— Faquarl

Jawaban:


5

dengan gdal, Anda dapat mewarnai gambar berdasarkan gdal_dem ( color_relief )

sintaks dari file konfigurasi warna berasal dari yang didukung oleh utilitas GRASS r.colors . File tabel warna ESRI HDR (.clr) juga cocok dengan sintaks itu. Komponen alfa dan dukungan tab dan koma sebagai pemisah adalah ekstensi spesifik 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

Lihat juga contoh saya yang diperluas di sini: gis.stackexchange.com/questions/130199/...
— AndreJ

tautan langsung ke jawaban @ AndreJ: gis.stackexchange.com/a/132690/49134
— Tom Saleeba

ya, terima kasih, pertanyaan-pertanyaan tahun 2015 itu harus ditandai sebagai duplikat tetapi jawaban AndreJ lebih detail daripada saya.
— radouxju
Dengan menggunakan situs kami, Anda mengakui telah membaca dan memahami Kebijakan Cookie dan Kebijakan Privasi kami.
Licensed under cc by-sa 3.0 with attribution required.