-
Notifications
You must be signed in to change notification settings - Fork 209
Open
Description
Context is I'm just trying to export geotiffs with EPSG:4326 CRS, and then importing/exporting the result which yields to this error.
I'm trying to read an input geotiff via fromBlob, edit its raster values, and export via writeArrayBuffer but exporting yields the below errors:
[geotiff.js] couldn't get TIFFTagLocation for GeogSemiMajorAxisGeoKey [geotiffwriter.js:469:17](http://localhost:5173/node_modules/geotiff/dist-module/geotiffwriter.js)
[geotiff.js] couldn't get TIFFTagLocation for GeogInvFlatteningGeoKey
These errors redirect to these lines:
geotiff.js/src/geotiffwriter.js
Lines 460 to 470 in c0c5f76
| if (fieldTagTypes[KeyID] === 'SHORT') { | |
| Count = 1; | |
| TIFFTagLocation = 0; | |
| valueOffset = metadata[geoKey]; | |
| } else if (geoKey === 'GeogCitationGeoKey') { | |
| Count = metadata.GeoAsciiParams.length; | |
| TIFFTagLocation = Number(name2code.GeoAsciiParams); | |
| valueOffset = 0; | |
| } else { | |
| console.log(`[geotiff.js] couldn't get TIFFTagLocation for ${geoKey}`); | |
| } |
Could it be that GeogSemiMajorAxisGeoKey and GeogInvFlatteningGeoKey are DOUBLE according to the geotiff spec and
- mappings should be added in file globals.js to the
fieldTagTypesobject, where 2057 and 2059 should be DOUBLE? - and the case
fieldTagTypes[KeyID] === 'DOUBLE'should be handled properly in theGeoKeyDirectoryobject? Is it simply a matter of Count = 2 in the DOUBLE case?
For reference, here is an extract of the read/write code, parsing geoMetadata on read and exploding it into the metadata object passed to writeArrayBuffer.
const tiff = await fromBlob(file);
const image = await tiff.getImage();
const rasters = await image.readRasters({ interleave: true });
const geoMetadata = {
geoKeys: image.getGeoKeys(),
fileDirectory: image.fileDirectory,
}
const { ModelPixelScale, ModelTiepoint, ImageWidth: width, ImageLength: height } = geoMetadata.fileDirectory;
const metadata = {
// GeographicTypeGeoKey: geoMetadata.geoKeys.GeographicTypeGeoKey,
width,
height,
ModelPixelScale,
ModelTiepoint,
// ...geoMetadata.fileDirectory
...(geoMetadata.geoKeys),
// couldn't get TIFFTagLocation for GeogSemiMajorAxisGeoKey, GeogInvFlatteningGeoKey
};
const metadata_ = JSON.parse(JSON.stringify(metadata)); // deep clone copy
const arrayBuffer = await writeArrayBuffer(raster, metadata_);Metadata
Metadata
Assignees
Labels
No labels