Changing the Projection of the geoTiff to WGS84 in javascript/node.js

342 Views Asked by At

I am working in a react.js project where I am having a geoTiff file of projection "EPSG: 24378" and I want to show it in the leaflet map. I am using "georaster" and "georaster-layer-for-leaflet" to show geoTiff on the map.
Is there anyway to convert the projection of the geoTiff file from "EPSG: 24378" to "WGS84" (lat/lon) and show it in the map? (note : node.js environment is also available as its a offline project).
I have tried "geotiff" and "proj4" library but it was not succesfull. project description : react.js application with react-leaflet and georaster. code :

import proj4 from 'proj4';
import geotiff from 'geotiff';



const wgs84 = '+proj=longlat +datum=WGS84 +no_defs';
const webMercator = '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext  +no_defs';


const transform = proj4(webMercator,wgs84);
...
...
// getting the arraybuffer
...
...
const tiff = await geotiff.fromArrayBuffer(arrayBuffer);
const image = await tiff.getImage();
const geoKeys = await image.getGeoKeys();
const matrix = geoKeys.modelTransformation;
const cornerCoords = geoKeys.cornerCoords;

const transformedImageData = transformImageData(image.getData(), matrix, cornerCoords, transform);

But here everytime "matrix" and "cornerCoords" comes undefined. I have tried with different geoTiff-files too.

Desired output : I want to upload the geotiff file of different projection and it should get placed on the leaflet map after the conversion to "WGS84" projection format.

1

There are 1 best solutions below

0
On

I suggest you do the reprojection of the geoTiff file, in other words, change the SRS. You could do that in diferent ways, using mapproxy, or using gdal, or using Qgis

Then you could use natively WGS84 in a Leaflet webmap