(英国)裁剪地图上 x 和 y 的墨卡托经度和纬度计算

我有这张图片.这是英国的地图(不包括南爱尔兰):

I have this image. It's a map of the UK (not including Southern Ireland):

我已经成功地获得了一个纬度和经度,并将其绘制在这张地图上,方法是获取英国最左边的经度和最右边的经度,并使用它们来计算在地图上放置点的位置.

I have successfully managed to get a latitude and longitude and plot it onto this map by taking the leftmost longitude and rightmost longitude of the UK and using them to work out where to put the point on the map.

这是代码(用于Processing.js,但可以用作js或任何东西):

This is the code (for use in Processing.js but could be used as js or anything):

// Size of the map
int width = 538;
int height = 811;
// X and Y boundaries
float westLong = -8.166667;
float eastLong = 1.762833;
float northLat = 58.666667;
float southLat = 49.95;

void drawPoint(float latitude, float longitude){

 fill(#000000);

 x = width * ((westLong-longitude)/(westLong-eastLong));
 y = (height * ((northLat-latitude)/(northLat-southLat)));

 console.log(x + ", " + y);
 ellipseMode(RADIUS);
 ellipse(x, y, 2, 2);    

}

但是,我无法在这些值上实现墨卡托投影.这些图相当准确,但还不够好,这个投影可以解决它.

However, I haven't been able to implement a Mercator projection on these values. The plots are reasonably accurate but they are not good enough and this projection would solve it.

我不知道该怎么做.我找到的所有例子都在解释如何为全世界做这件事.This 是一个很好的示例资源,用于解释如何实现投影,但我没有能够让它工作.

I can't figure out how to do it. All the examples I find are explaining how to do it for the whole world. This is a good resource of examples explaining how to implement the projection but I haven't been able to get it to work.

另一个资源是 英国的极点,在那里我得到了纬度和经度英国周围的边界框的值.他们也在这里:

Another resource is the Extreme points of the United Kingdom where I got the latitude and longitude values of the bounding box around the UK. They are also here:

northLat = 58.666667; 
northLong = -3.366667; 
eastLat = 52.481167; 
eastLong = 1.762833; 
southLat = 49.95;
southLong = -5.2; 
westLat = 54.45;
westLong = -8.166667;

如果有人能帮我解决这个问题,我将不胜感激!

If anyone could help me with this, I would greatly appreciate it!

谢谢

推荐答案

我认为值得记住的是,并非所有平面地图都是墨卡托投影.如果不特别了解该地图,很难确定.您可能会发现世界上一小部分区域的大多数地图更可能是 圆锥 类型的投影,其中地图上的感兴趣区域比全球墨卡托投影上的更平坦".离赤道越远,这一点尤其重要(而英国离它也足够远).

I think it's worthwhile to keep in mind that not all flat maps are Mercator projections. Without knowing more about that map in particular, it's hard to be sure. You may find that most maps of a small area of the world are more likely to be a conical type projection, where the area of interest on the map is "flatter" than would be on a global Mercator projection. This is especially more important the further you get away from the equator (and the UK is far enough away for it to matter).

您可以使用您正在尝试的计算获得足够接近",但为了获得最佳准确性,您可能需要使用具有明确投影的地图,或者创建自己的地图.

You may be able to get "close enough" using the calculations you're trying, but for best accuracy you may want to either use a map with a well-defined projection, or create your own map.

相关文章