[MetaCRS] Noob Question on Proj4js

Steven Sokol steven.sokol at gmail.com
Mon Jun 17 16:52:09 PDT 2013


Greetings.  I'm working with maps provided by the FAA* which include a
world file and some meta data. I'm trying to work out how to convert a
given lat/lon to a pixel coordinate on the map. I seem to be having some
difficulty converting the map metadata into a valid constructor.  Here's
the meta data I have:

*Spatial_Reference_Information:**Horizontal_Coordinate_System_Definition:**
Planar:**Map_Projection:**Map_Projection_Name:* Lambert Conformal Conic*
Lambert_Conformal_Conic:**Standard_Parallel:* 33.330000*Standard_Parallel:*
 38.660000*Longitude_of_Central_Meridian:* -93.470000*
Latitude_of_Projection_Origin:* 38.167000*False_Easting:* 0.000000*
False_Northing:* 0.000000*Planar_Coordinate_Information:**
Planar_Coordinate_Encoding_Method:* row and column*
Coordinate_Representation:**Abscissa_Resolution:* 63.464794*
Ordinate_Resolution:* 63.464794*Planar_Distance_Units:* meters*
Geodetic_Model:**Horizontal_Datum_Name:* North American Datum of 1983*
Ellipsoid_Name:* Geodetic Reference System 80*Semi-major_Axis:*
 6378137.000000*Denominator_of_Flattening_Ratio:* 298.257222

And here is the constructor I created:

Proj4js.defs["EPSG:9999"] = "+proj=lcc +lat_0=38.167000 +lon_0=-93.470000
+x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs";


Here is the data from the world file:

63.4647940000
0.0000000000
0.0000000000
-63.4647940000
-387637.9055536929
-24695.2385093325

And here is the code** I'm running:

<SCRIPT type="text/javascript">
// Put your projection definition here.
Proj4js.defs["EPSG:9999"] = "+proj=lcc +lat_0=38.167000 +lon_0=-93.470000
+x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs";

var A = 63.4647940000,
    D = 0.00000000000,
    B = 0.00000000000,
    E = -63.4647940000,
    C = -387637.9055536929,
    F = -24695.2385093325;

function frompixel(px, py) {
    px += 0.5; // Add a half-pixel offset to get the coordinates of the
centre of the pixel.
    py += 0.5;
    return {x : A*px + B*py + C, y: D*px + E*py + F};
}

function tolatlong(x, y) {
    var src = new Proj4js.Proj('EPSG:9999'); // Same code as you defined
above. Alternatively, let proj4js get the definition from
spatialreference.org
    var dest = new Proj4js.Proj('EPSG:4326');
    var p = frompixel(x, y);

    document.write('From coordinates: ');
    document.writeln(p.x, ',', p.y);

    // This is the bit that does the transformation from map coordinates to
lat/long.
    Proj4js.transform(src, dest, p);
    document.write('To lat/long: ');
    document.writeln(p.x, ',', p.y);
}

tolatlong(3000, 2000);
</SCRIPT>

Unfortunately, this generates an error:

phi2z has NoConvergence

And the unlikely results:

>From coordinates: -197211.7911566929,-151656.55890633247 To lat/long:
-11299403.303493915,-8689280.760810006

Any suggestions?


* You can download the sectional chart I'm using here:
http://avn.faa.gov/content/aeronav/sectional_files/Kansas_City_90.zip

** Original found here:
http://gis.stackexchange.com/questions/8430/convert-x-y-position-in-georeferenced-image-with-world-file-to-longitude-lat

-- 
Steven Sokol
408 Camelot Drive
Liberty, MO 64068

mobile: +1 816-806-8844
fax: +1 816-817-0441
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/metacrs/attachments/20130617/3f90fcfa/attachment.html>


More information about the MetaCRS mailing list