如何保存由node- dal创建的GeoTIFF的空间引用



我试图使用node- dal创建GeoTIFF并设置其空间引用。空间引用来自现有文件,并编写如下代码

// read an existing file and get its spatial reference
let dataset = gdal.open(filePath);
this.bandData = dataset.bands.get(1);
this.rasterSize = dataset.rasterSize;
this.geoTransform = dataset.geoTransform;
this.spatialReference = dataset.spatialReference;
// save the same spatial reference to a new file
let driver = gdal.drivers.get('GTiff');
let dataset = driver.create(filePath, this.rasterSize.x, this.rasterSize.y, 1, gdal.GDT_Byte);
let bandData = dataset.bands.get(1);
bandData.pixels.write(0, 0, this.rasterSize.x, this.rasterSize.y, data);
dataset.spatialReference = this.spatialReference;
dataset.geoTransform = this.geoTransform;
dataset.flush();

然而,当我用QGIS加载保存的文件时,它表明GeoTIFF没有任何投影信息。

完整的代码可以在这里找到

这显然是一个打字错误:-(

this.spatialReference = dataset.spatialReference;
应该

this.src = dataset.src;

最新更新