Як додати кольорову таблицю до єдиної смуги за допомогою GDAL?


11

У мене є 1-діапазонний файл GeoTIFF. Тлумачення кольорів для смуги - сірий. Я хочу таблицю кольорів, щоб перетворити мою Col.tiffна Col.jpegабо Col.png.

Я спробував помістити таблицю кольорів у цей тиф за допомогою .vrt:

gdal_translate -of VRT  Col.tiff Col.vrt

потім додаючи в .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>

І перекладіть знову:

gdal_translate Col.vrt Col.tiff

Але він відповів:

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.

Як я можу це зробити?

Для інформації є gdalinfo для групи:

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

Які значення максимуму / хв має ваш тиф? Це Float64, то як це десяткове значення повинно відповідати цілим значенням для палітри кольорів?
— AndreJ

Помилка говорить про те, що висновок повинен бути типу Byte або UInt16. Можливо, вам слід додати "-ot UInt16" до команди gdal_translate.
— користувач30184

Дякую, це працює зараз, мені просто потрібно знайти гарні кольори :)
— Faquarl

@AndreJoost Що я зробив - це прийняття значень max / min та розподіл їх між 255 класами. Потім для кожного значення я кладу колір.
— Faquarl

Нарешті, я створив сценарій Python, щоб створити новий тиф з тією ж інформацією, за винятком того, що є 4-смуга (rgba)
— Faquarl

Відповіді:


5

за допомогою gdal ви можете розфарбувати зображення на основі gdal_dem ( color_relief )

синтаксис файлу конфігурації кольорів походить від того, що підтримується утилітою GRASS r.colors . Файли кольорових таблиць кольорів ESRI HDR (.clr) також відповідають цьому синтаксису. Альфа-компонент та підтримка вкладки та кома як роздільники є специфічними розширеннями 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

Дивіться також мій розширений приклад тут: gis.stackexchange.com/questions/130199/…
— AndreJ

посилання безпосередньо на відповідь @ AndreJ: gis.stackexchange.com/a/132690/49134
— Том Салееба

так, дякую, ці запитання у 2015 році мають бути позначені як повторювані, але відповідь AndreJ більш детальна, ніж моя.
— radouxju
Використовуючи наш веб-сайт, ви визнаєте, що прочитали та зрозуміли наші Політику щодо файлів cookie та Політику конфіденційності.
Licensed under cc by-sa 3.0 with attribution required.