将纬度/经度转换为图像坐标(像素坐标) [英] Conversion of latitude/longtitude into image coordinates (pixel coordinates)

查看:437
本文介绍了将纬度/经度转换为图像坐标(像素坐标)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从MODIS拍摄了一张地理图像,我希望根据经度和纬度从该源图像中获取一个像素(x,y)。我需要一个公式,如何计算这个没有投影,任何帮助将是适当的。



我尝试过:



math - 将经度和纬度坐标转换为地图像素的图像X和Y坐标Java - Stack Overflow [ ^ ]

I have taken a geotiff image from MODIS and i want to get a pixel (x,y) from that source image based on the longitude and latitude. I need a formula that how to calculate this without projection, any help would be appriciate.

What I have tried:

math - Convert longitude and latitude coordinates to image of a map pixels X and Y coordinates Java - Stack Overflow[^]

推荐答案

您需要以像素为单位的图像尺寸(宽度高度),指定像素位置的纬度/经度参考点(例如 lat0 lon0 at at x = y = 0),并且图像覆盖了纬度/经度(例如,通过在最大x和y处具有另一个参考点)。



第一步是计算每个度数的像素比例因子:

You need the image dimension in pixels (width and height), a lat/lon reference point at a specified pixel position (e.g. lat0 and lon0 at x = y = 0), and the lat/lon degress covered by the image (e.g. by having another reference point at max. x and y).

First step is calculating the scaling factors in pixels per degree:
double scale_x = width / lon_range;
double scale_y = height / lat_range;





现在你可以获得像素位置:



Now you can get the pixel positions:

double x = (lon - lon0) * scale_x;
double y = (lat - lat0) * scaly_y;





最后将它们转换为具有舍入的整数:



Finally convert them to integers with rounding:

int xp = static_cast<int>((x > 0) ? x + 0.5 : x - 0.5);
int yp = static_cast<int>((y > 0) ? y + 0.5 : y - 0.5);</int></int>





注意:这只是从零开始(尚未测试过)。



Note: This is just from scratch (had not tested it).


这篇关于将纬度/经度转换为图像坐标(像素坐标)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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