Convert Lat/Longs to X/Y Coordinates on Albers projection map

I have a map with Albers projection and i have Lat and Long of some location and i need to draw a point on this image. I know that this map was built with Albers projection using standard parallels on 52 and 64 and WGS 84. I tryed to implement this formulas in Javascript, but result seems wrong. I have no idea what to do. I found a few similar question, but they didn't gave me answer for my question.

// lat and long of left top corner
f0 = 66 * (Math.PI/180); 
a0 = 36 * (Math.PI/180);
// lat and long of my point
f = 55 * (Math.PI/180);
a = 37 * (Math.PI/180); 
// Standart parallers
f1 = 52 * (Math.PI/180);
f2 = 64 * (Math.PI/180);

n = 1/2 * (Math.sin(f1)+Math.sin(f2));
c = Math.pow(Math.cos(f1),2) + 2*n*Math.sin(f1);
t = n*(a*(180/Math.PI) - a0*(180/Math.PI))* (Math.PI/180);
p0 = 1/n * Math.sqrt(c-2*n*Math.sin(f0));
p=1/n*Math.sqrt(c-2*n*Math.sin(f));

x=p*Math.sin(t);
y=p0-p*Math.cos(t);

Thanks.

Answers:

Answer

Problem solved Ok, i need for calculation also Central Meridian for my map. This code works fine.

function albers(lat, lng) {

    var lat0 = 66 * (Math.PI/180),   // Latitude_Of_Origin
        lng0 = 105 * (Math.PI/180),  // Central_Meridian
        phi1 = 52 * (Math.PI/180),   // Standard_Parallel_1
        phi2 = 64 * (Math.PI/180),  // Standard_Parallel_2


        n = 0.5 * (Math.sin(phi1) + Math.sin(phi2)),
        c = Math.cos(phi1),
        C = c*c + 2*n*Math.sin(phi1),
        p0 = Math.sqrt(C - 2*n*Math.sin(lat0)) / n,
        theta = n * (lng * Math.PI/180 - lng0),
        p = Math.sqrt(C - 2*n*Math.sin(lat* Math.PI/180)) / n,

        x = p * Math.sin(theta),
        y = p0 - p * Math.cos(theta)

        return [x,y]
}

All credits goes to https://gist.github.com/RandomEtc/476238

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.