I'm facing a challenge in JavaScript where I need to create a new dataset from a 2D array. Despite my efforts, I can't seem to figure out the necessary steps from the documentation.
It seems that in order to create this new dataset, I must utilize gdal.open
in write mode to enable data writing. However, I am struggling to understand how to populate this blank raster with actual data:
const driver = gdal.drivers.get('GTiff');
const xSize = 3;
const ySize = 3;
const bandCount = 1;
const dataType = gdal.GDT_Int32;
const dataset = await gdal.openAsync('output.tif', 'w', driver, xSize, ySize, bandCount, dataType);
Let's assume I have the following 2D array of data:
// retrieved from an hdf5 file
const data = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
];
What is the best approach for updating my dataset with the provided data?