0

Using gdal2tiles leaflet I am rendering raster image GeoTiff image on browser. https://github.com/commenthol/gdal2tiles-leaflet

What I am doing to convert from projected map to get actual coordinates (lat,lng)

// GeoTransform data

var xoff = 424562.64403639885,
        a   = 0.5064676564009486,
        b   = 0,
        yoff = 3285265.740653501,
        d   = 0,
        e   = -0.5064676564009355;


var X_proj = a * coords.x + b * coords.y + xoff
var Y_proj = d * coords.x + e * coords.y + yoff

Where coords.x and coords.y is ( {x: 15336, y: 14088} ) pixel point of browser map. Returned from click event as from example : https://commenthol.github.io/leaflet-rastercoords/.

Then Converting raster points (X_proj and Y_proj) using proj4js to get lat,lng

Now I have a set of coordinates (lal, lng) fetched from Google map.

What I am trying to do here is draw point on my map (generated from gdal2tiles leaflet) displayed on browser. How to I make it point to actual location (lat, lng).

What I want to acheive is the reverse of above solution.

1 Answer 1

0

By solving it with linear equations. I generated below code to give me coords.x and coords.

var coordsToPoint = function(X_proj, Y_proj) {

    var x = ( ( b * (Y_proj - yoff) ) - ((X_proj - xoff) * e)  ) / ( d * b - a * e );
    var y = ( (( a * ( Y_proj - yoff ) ) - ( d * ( X_proj - xoff ) )) /  ( (a * e) - ( d * b ) ) );
    return {
        x: x,
        y: y
    };
};

Not the answer you're looking for? Browse other questions tagged or ask your own question.