Friday 28 October 2016

raster - Convert x, y position in georeferenced image (with world file) to longitude, latitude?


What steps do I need to do in order to calculate longitude and latitude for a specific pixel in a georeferenced image? For example this image http://www.shadedreliefarchive.com/medit_Mideast_africa_copy.html contains information, .tfw file:


1627.32174969982000 
0.00000000000000
0.00000000000000
-1627.32174969982000

-4957506.34276705000000
6096922.76188281000000

and .prj file:


PROJCS["Lambert Azimuthal Equal-Area",
GEOGCS["GCS_WGS_1984",
DATUM["D_WGS_1984", SPHEROID["WGS_1984", 6378137, 298.257223563]],
PRIMEM["Greenwich", 0],
UNIT["Degree", 0.017453292519943295]],
PROJECTION["Lambert_Azimuthal_Equal_Area"],

PARAMETER["false_easting", 0],
PARAMETER["false_northing", 0],
PARAMETER["latitude_of_origin", 0],
PARAMETER["central_meridian", 20],
PARAMETER["xy_plane_rotation", 0],
UNIT["Meter", 1]]

I've created this snippet of javascript to compute new x1 and y1 values for specific pixels in the image:


var A = 1627.32174969982000,
D = 0.00000000000000,

B = 0.00000000000000,
E = -1627.32174969982000,
C = -4957506.34276705000000,
F = 6096922.76188281000000;

function x1(x, y) { return A*x + B*y + C; }

function y1(x, y) { return D*x + E*y + F; }

What more do I have to do to get longitude and latitude? For example C, F represents the top-left corner of the image, right? Then how do I translate C, F to get longitude and latitude?



I want do do it using javascript only, have looked at http://proj4js.org/ but don't really understand what to do with the values I get...




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...