图像像素X、Y坐标为经纬度

Image Pixel X,Y coordinates to Lat/Lon

本文关键字:坐标 经纬度 像素 图像      更新时间:2023-09-26

我有一个独特的问题:投影和从图像中获得经纬度坐标。

我有一张800 x 600像素的美国图像,并且我知道投影(原点中心为-75°的极立体图像),图像的左下纬度/经度和右上纬度/经度。我已经把图像放到一个网页上,我可以将鼠标放在图像上,并从div标签中的图像中获得x和y"像素"坐标。是否有一个简单的公式来帮助获得x/y像素坐标的经纬度?

我想要一个精简的过程,因为我有多个地图投影和图像大小。

下面是注释的js代码:

//these define lat/lon at the bounds of the image
var geo_left=-75;
var geo_right=75;
var geo_top=-75;
var geo_bottom=75;
//dimensions of the canvas
//i set it to 400x400 for example purposes
var canvas_width=400;
var canvas_height=400;
//get relative coordinate of pixel, should be on a scale of 0 to 1
var rel_x = pixel_x/canvas_width;
var rel_y = pixel_y/canvas_height;
//linear interpolate to find latitude and longitude
var latitude = geo_left+(geo_right-geo_left)*rel_x;
var longitude = geo_top+(geo_bottom-geo_top)*rel_y;