とらりもん - GeoTiffのカラーテーブルを変更する Diff
- Added parts are displayed like this.
- Deleted parts are displayed
like this.
2017/04/26 Jin Katagi
{{toc}}
! gdaldemコマンドを使う場合 / use gdaldem command.
多分これが一番お手軽。
I think this way is the most easy.
vim color_table.txt # 4 column is alpha channel?
0. 255 255 255 0
1. 255 0 0 0
2. 180 0 0 0
gdaldem color-relief -of GTiff input.tif color_table.txt output.tif
*[[参考|https://gis.stackexchange.com/questions/130199/changing-color-of-raster-images-based-on-their-data-values-gdal]]
! GRASS GISのr.colorsコマンドを使い場合 / use GRASS GIS command.
一旦GRASSの環境にtiffを読み込む必用がある。GRASS 6.X系と7.X系でコマンドの使い方が若干違う。
vim color_table.txt
0 255:255:255
1 255 0 0
2 180 0 0
grass # start GRASS envirionment
r.in.gdal input=input.tif output=input # import tif to GRASS
g.region rast=input # set region to the image
r.colros # change color, 書きかけ
cat color_table.txt | r.colors map=input rules=- # For GRASS 7.X.
# cat color_table.txt | r.colors map=input color=rules # For GRASS 6.X
r.out.gdal input=input output=input_change_color.tif # save as GeoTiff
*[[参考|https://grass.osgeo.org/grass72/manuals/r.colors.html]]
! gdalbuildvrtコマンドを使う場合 / use gdalbuildvrt command.
gdalbuildvrtでvrtを書き出し、直接vrtを変更して、tiffに戻す。
*[[参考|https://gis.stackexchange.com/questions/130199/changing-color-of-raster-images-based-on-their-data-values-gdal]]
{{toc}}
! gdaldemコマンドを使う場合 / use gdaldem command.
多分これが一番お手軽。
I think this way is the most easy.
vim color_table.txt # 4 column is alpha channel?
0. 255 255 255 0
1. 255 0 0 0
2. 180 0 0 0
gdaldem color-relief -of GTiff input.tif color_table.txt output.tif
*[[参考|https://gis.stackexchange.com/questions/130199/changing-color-of-raster-images-based-on-their-data-values-gdal]]
! GRASS GISのr.colorsコマンドを使い場合 / use GRASS GIS command.
一旦GRASSの環境にtiffを読み込む必用がある。GRASS 6.X系と7.X系でコマンドの使い方が若干違う。
vim color_table.txt
0 255:255:255
1 255 0 0
2 180 0 0
grass # start GRASS envirionment
r.in.gdal input=input.tif output=input # import tif to GRASS
g.region rast=input # set region to the image
# cat color_table.txt | r.colors map=input color=rules # For GRASS 6.X
r.out.gdal input=input output=input_change_color.tif # save as GeoTiff
*[[参考|https://grass.osgeo.org/grass72/manuals/r.colors.html]]
! gdalbuildvrtコマンドを使う場合 / use gdalbuildvrt command.
gdalbuildvrtでvrtを書き出し、直接vrtを変更して、tiffに戻す。
*[[参考|https://gis.stackexchange.com/questions/130199/changing-color-of-raster-images-based-on-their-data-values-gdal]]