Image Pixel X,y Coordinates To Lat/lon
I have a unique problem re: projections and obtaining lat/lon coordinates from an image. I have an 800 x 600 pixel image of the U.S., and I know the projection (Polar Sterographic
Solution 1:
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;
Post a Comment for "Image Pixel X,y Coordinates To Lat/lon"