在Albers投影图上将Lat / Longs转换为X / Y坐标

时间:2021-06-01 22:45:53

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.

我有一张Albers投影的地图,我有Lat和Long的某些位置,我需要在这张图片上画一个点。我知道这张地图是使用Albers投影在52和64以及WGS 84上使用标准平行线构建的。我试图在Javascript中实现这个公式,但结果似乎是错误的。我不知道该怎么做。我发现了一些类似的问题,但他们没有给我答案。

// 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.

谢谢。

1 个解决方案

#1


2  

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

问题解决好了,我需要为我的地图计算Central Meridian。这段代码工作正常。

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

所有学分都转到https://gist.github.com/RandomEtc/476238

#1


2  

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

问题解决好了,我需要为我的地图计算Central Meridian。这段代码工作正常。

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

所有学分都转到https://gist.github.com/RandomEtc/476238