From 69859c83af20c0df19d99fba3c475ce753e45acc Mon Sep 17 00:00:00 2001 From: Jodok Huber Date: Thu, 8 May 2025 14:39:47 +0200 Subject: [PATCH] Do not write ModelPixelScale or ModelTiepoint when ModelTransformationTag is present (see specs: http://geotiff.maptools.org/spec/geotiff2.6.html) --- src/geotiffwriter.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/geotiffwriter.js b/src/geotiffwriter.js index ea318477..c6bb79cb 100644 --- a/src/geotiffwriter.js +++ b/src/geotiffwriter.js @@ -355,7 +355,7 @@ export function writeGeotiff(data, metadata) { metadata.StripByteCounts = [numBands * height * width]; } - if (!metadata.ModelPixelScale) { + if (!metadata.ModelPixelScale && !metadata.ModelTransformation) { // assumes raster takes up exactly the whole globe metadata.ModelPixelScale = [360 / width, 180 / height, 0]; } @@ -367,7 +367,9 @@ export function writeGeotiff(data, metadata) { // if didn't pass in projection information, assume the popular 4326 "geographic projection" if (!metadata.hasOwnProperty('GeographicTypeGeoKey') && !metadata.hasOwnProperty('ProjectedCSTypeGeoKey')) { metadata.GeographicTypeGeoKey = 4326; - metadata.ModelTiepoint = [0, 0, 0, -180, 90, 0]; // raster fits whole globe + if (!metadata.ModelTransformation) { + metadata.ModelTiepoint = [0, 0, 0, -180, 90, 0]; // raster fits whole globe + } metadata.GeogCitationGeoKey = 'WGS 84'; metadata.GTModelTypeGeoKey = 2; }