將某個目錄下land數據全部賦色
import org.gdal.gdal.Band;
import org.gdal.gdal.ColorTable;
import org.gdal.gdal.Dataset;
import org.gdal.gdal.gdal;
import org.gdal.gdalconst.gdalconstConstants;
import java.awt.*;
import java.io.File;
public class Coloration {
public static void main(String[] args) {
File file = new File("E:\\taizhiminFile\\land\\10m");
File[] files = file.listFiles();
gdal.AllRegister();
for (File f : files) {
String imgPath = f.getPath();
Dataset ds = gdal.Open(imgPath, gdalconstConstants.GA_Update);
Band band = ds.GetRasterBand(1);
ColorTable colorTable = new ColorTable();
colorTable.SetColorEntry(10, new Color(163, 255, 115));
colorTable.SetColorEntry(20, new Color(38, 115, 0));
colorTable.SetColorEntry(30, new Color(76, 230, 0));
colorTable.SetColorEntry(40, new Color(112, 168, 0));
colorTable.SetColorEntry(60, new Color(0, 92, 255));
colorTable.SetColorEntry(80, new Color(197, 0, 255));
colorTable.SetColorEntry(90, new Color(255, 170, 0));
colorTable.SetColorEntry(100, new Color(0, 255, 197));
colorTable.SetColorEntry(120, new Color(255, 255, 255));
band.SetColorTable(colorTable);
ds.FlushCache();
}
}
}