I am trying to create a list of <lat, long, elevation> for each pixel in a geotiff.
The script below seems to be getting values, but when I check the lat/longs on the same geotiff imported into Arcgis Pro I get different values.
import { fromFile } from 'geotiff'; //Script assumes EPSG:4326 async function readDemToXyz(filename) { const tiff = await fromFile(filename); const image = await tiff.getImage(); const width = image.getWidth(); const height = image.getHeight(); const bbox = image.getBoundingBox(); const elevationData = await image.readRasters({ interleave: true }); const deltaX = (bbox[2] - bbox[0]) / width; const deltaY = (bbox[3] - bbox[1]) / height; let xyzData = []; for (let i = 0; i < height; i++) { for (let j = 0; j < width; j++) { const x = bbox[0] + j * deltaX; const y = bbox[1] + i * deltaY; const z = elevationData[i * width + j]; console.log(`Coordinates: (${x.toFixed(9)}, ${y.toFixed(9)}), Elevation: ${z}`); xyzData.push([x, y, z]); } } return xyzData; } // Usage const filename = 'example.tif'; readDemToXyz(filename).then(xyzData => { //console.log(xyzData.slice(0, 100)); // Print the first 100 [x, y, MSL] values //console.log("Printing all values") //console.log(xyzData) });
example console.log Coordinates: (-83.298493884, 34.970485560), Elevation: 1079.0888671875
example lat/long being checking Arcgis Pro
image showing that the map crs
image showing export of dem geotiff crs
I was expecting that <lat, long, elevation> values would be the same in the console.log as they were in Arcgis Pro on the same Geotiff.
Instead they are different and I'm not sure why.