Image Pixel X,Y坐标为Lat / Lon [英] Image Pixel X,Y coordinates to Lat/Lon

查看:136
本文介绍了Image Pixel X,Y坐标为Lat / Lon的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a unique problem re: projections and obtaining lat/lon coordinates from an image.

我有800 x 600像素的美国图像,而我知道投影(Polar Sterographic具有-75 lon中心原点),左下lat / lon和右上lat / lon的图像。我已将图像放入网页,我可以将鼠标悬停在图像上,并从div标签中的图像中获取x和y像素坐标。是否有一个简单的公式来帮助获得x / y像素坐标的纬度和经度?

I have an 800 x 600 pixel image of the U.S., and I know the projection (Polar Sterographic with a -75 lon center of origin), lower left lat/lon, and upper right lat/lon of the image. I've put the image into a webpage and I am able to mouse over the image and obtain the x and y "pixel" coordinates from the image in the div tag. Is there a simple formula to help obtain the lat and lon of the x/y pixel coordinates?

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

I would like a streamlined process because I have multiple map projections and image sizes.

推荐答案

以下是评论js代码,了解如何操作:

Here's the commented js code for how to do it:

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

这篇关于Image Pixel X,Y坐标为Lat / Lon的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆