function getimgdata(raster, width, height, colorscale) {
const data = new Uint8ClampedArray(width * height * 4);
for (let i = 0; i < raster.length; i++) {
let color = d3.color(colorscale(raster[i]))|| {r:0,g:0,b:0};
data[i * 4] = color.r;
data[i * 4 + 1] = color.g;
data[i * 4 + 2] = color.b;
data[i * 4 + 3] = isNaN(raster[i]) || raster[i] == -3.4028234663852886e+38 || raster[i] == 3.4028234663852886e+38 || raster[i] == 255 ? 0 : 255;
}
return new ImageData(data, width, height);
}