将经度(epsg:4326)转换为EPSG:3857?


11

我正在研究所涉及的数学,以了解如何将给定的十进制纬度和经度转换为EPSG:3857。任何人都可以指出一个好的参考文献或可能的Ppython / C / C ++ / Java库源代码来检查数学吗?


pyproj上大笑,这在GIS SE上非常常用
基因

带有数学运算的python代码twms.googlecode.com/hg/twms/projections.py
Mapperz

Answers:



4

此代码段是C#,并使用称为顶点的数组保存[x,y]

double smRadius = 6378136.98;
double smRange = smRadius * Math.PI * 2.0;
double smLonToX = smRange / 360.0;
double smRadiansOverDegrees = Math.PI / 180.0;

...

// compute x-map-unit
vertex[0] *= smLonToX;

double y = vertex[1];

// compute y-map-unit
if (y > 86.0)
{
    vertex[1] = smRange;
}
else if (y < -86.0)
{
    vertex[1] = -smRange;
}
else
{
    y *= smRadiansOverDegrees;
    y = Math.Log(Math.Tan(y) + (1.0 / Math.Cos(y)), Math.E);
    vertex[1] = y * smRadius; 
}

0

跟进ICS中@Russel的回答。今天,我重写了他的代码,以在R中将wgs84(epsg:4326)坐标转换为wgs84 / pseudo mercator(epsg:3857):

vertex = list(x_coordinate, y_coordinate)
smRadius = 6378136.98
smRange = smRadius * pi * 2.0
smLonToX = smRange / 360.0
smRadiansOverDegrees = pi / 180.0

vertex[[1]] = vertex[[1]] *smLonToX

y = vertex[[2]]

if (y > 86.0){
  vertex[[2]] = smRange
} else if (y < -86.0){
  vertex[[2]] = -smRange
} else {
  y = y * smRadiansOverDegrees
  y = log(tan(y) + (1.0 / cos(y)), base = exp(1))
  vertex[[2]] = y * smRadius
}
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.