When reading COG (Cloud Optimized GeoTIFF) or original GeoTIFF of a DEM/DTM (elevation map) file using Geotiff.js directly or geoblaze, elevation at a point through conversion of coordinates to pixels, it is returning null.
I'm getting the coordinates from QGIS by copying coordinates(-79.57667578, 8.89886421) (projection EPSG: 32617) at a point inside the DEM. QGIS is able to give elevation correctly at that point.
Although, it works in some sample DEM files retrieved from the internet, and shows correct elevation, I'm not sure why some seem to have issues. The rasters having issues also seem to have high x, y pixel values on conversion from coordinates, whereas the ones in which elevation is working it seems to be just 2-3 digits long.
For one raster - EPSG:32617 is the Projection. The [lon,lat] array I'm passing to geoblaze.identify(docs.geoblaze.io/#identify) is [-79.57667578, 8.89886421] which returns null.
geoblaze
const point = [-79.57667578, 8.89886421];
const results = await geoblaze.identify(signedurl, point);
console.log("Identify", point, "Value", results);
Prints - Identify [ -79.57667578, 8.89886421 ] Value null
Using geotiff.js directly and converting the above lat lng to pixel coordinates gives Px,Py as -6563580,9844235 and this returns 0 as the value when trying to read a 1x1 window from above pixel value in raster.
geotiff.js
const widthPct = (longitude - bbox[0]) / bboxWidth;
const heightPct = (latitude - bbox[1]) / bboxHeight;
const xPx = Math.floor(pixelWidth * widthPct);
const yPx = Math.floor(pixelHeight * (1 - heightPct));
const window = [xPx, yPx, xPx + 1, yPx + 1];
const data = await image.readRasters({ window });
console.log("Value", xPx, yPx, data);
Prints - Value -6563580 9844235 [ Float32Array(1) [ 0 ], width: 1, height: 1 ]
Unable to figure out what's causing this issue.