Closed jfoclpf closed 4 months ago
@jfoclpf
quick-lru
is listed in the dependencies. Are you sure you properly installed geotiff.js?
@jfoclpf
quick-lru
is listed in the dependencies. Are you sure you properly installed geotiff.js?
yes, via npm install geotiff
then I used require
I found this https://nodejs.org/api/esm.html#import-expressions
it should be possible to run
import('geotiff').then(module => { })
But I still need to figure out for this specific case
If others stumble with this problem, that's how I solved it, with dynamic import
const lerp = (a, b, t) => (1 - t) * a + t * b
function transform(a, b, M, roundToInt = false) {
const round = (v) => (roundToInt ? v | 0 : v);
return [
round(M[0] + M[1] * a + M[2] * b),
round(M[3] + M[4] * a + M[5] * b),
];
}
(async () => {
const fs = require('fs')
const { fromUrl, fromArrayBuffer, fromBlob } = await import('geotiff')
// Load our data tile from url, arraybuffer, or blob, so we can work with it:
const arrBuffer = fs.readFileSync('tif/Vs6UB-2019_2__DEM1__coverage_20240326220529.tif').buffer
const tiff = await fromArrayBuffer(arrBuffer)
const image = await tiff.getImage(); // by default, the first image is read.
/* ... */
console.log(`The elevation at (${lat.toFixed(6)},${long.toFixed(6)}) is ${elevation}m`);
})()
This workaround does not succeed in my project, possibly due to using a newer version of NodeJS Node.js v20.10.0
The documentation mentions
Though it's not working with require:
Apparently is one of your dependencies, named
quick-lru