1

I've looked into a few other posts/libraries as far as converting between State Plane (Easting/Northing) to get a Lat/Lon value, however I've run into some trouble.

I saw here (https://stackoverflow.com/questions/1676958/coordinate-transform) that there were a few libraries that would be useful in doing such a conversion.

I decided to give Java Map Projection Library a shot because it seemed to be more straight forward in terms of usage than say GDAL or CTS.

But.. alas that is not the case. Below you can see some dumby code that I am trying to use to get the correct coordinates, but it is outputting (garble) information that I'm not quite sure about.

I guess I have not found 'documentation' or examples as to how the code is intended to be used, and I am not extremely familiar with coordinate based systems, only that I need lat lon. Which leads me to the reason I am doing this.

I am developing a product that uses WorldWind 2.0 SDK, and in order to plot points, it is my understanding that it needs to be in the form of Latitude and Longitude.

I have roughly 2000-n rows in a database, all containing State Plane based coordinates that I need to programmatically convert to lat/lon in order to plot points on a map.

So I guess I am asking if anyone knows of preexisting documentation/examples that relate to my problem, or if someone can spot out what I am doing wrong.

Code:

import com.jhlabs.map.proj.Projection;
import com.jhlabs.map.proj.ProjectionFactory;
import java.awt.geom.Point2D;

public class Conversion()
{
    public static void main(String[] args)
    {
          // Easting  = 01495728
          // Northing = 00663563

          Projection epsg = ProjectionFactory.getNamedPROJ4CoordinateSystem("nad27:3402");
          Point2D.Double pEPSG = new Point2D.Double(01495728, 00663563);
          Point2D.Double test = new Point2D.Double(0, 0);
          epsg.transform(pEPSG, test);

          System.out.println(test.x + ", " + test.y);
          System.out.println(epsg.getPROJ4Description());
     }
}

This code outputs:

856515.186461105, 5819341.3114590645
+proj=lcc +a=6378249.145 +es=0.006803481196021999 +lon_0=-82d30 +lat_0=38d00 x_0=609601.2192024384 +y_0=0.0

Using this code

Code 2:

        Projection epsg2835 = ProjectionFactory.getNamedPROJ4CoordinateSystem("nad27:3402");
        Point2D.Double pEPSG2835 = new Point2D.Double(01495728.0, 00663563.0);
        Point2D.Double test = new Point2D.Double(0, 0);
        epsg2835.inverseTransform(pEPSG2835, test);
        System.out.println("x: " + test.getX() + "\ny: " + test.getY());
        System.out.println(epsg2835.getPROJ4Description());

I get,

x: -71.5472000389142
y: 43.48764838968165
+proj=lcc +a=6378249.145 +es=0.006803481196021999 +lon_0=-82d30 +lat_0=38d00 +x_0=609601.2192024384 +y_0=0.0

I am not entirely familiar with the second line, only that it is outputting in Lambert Conic Conformal form. Otherwise, from my understanding, I am giving it the NAD27 Zone (3402) of South Ohio, Easting point of 001495728 and Northing point of 00663563.

After manually doing the conversion from http://www.ngs.noaa.gov/cgi-bin/spc_getgp.prl It shows that is should be

 ===========================================================
          East(Feet)        North(Feet)      Datum     Zone
 INPUT =  01495728.0        00663563.0       NAD27     3402
 ===========================================================

     LATITUDE        LONGITUDE         AREA
     DD MM SS.sssss  DDD MM SS.sssss       
     --------------  ---------------   ----
     39 48 29.30270   84 17 42.17103   3402

(this is DDD MMM SSSS) but can be converted to decimal.

Any help is appreciated,

Mike

PS: I am not stuck on using this library so if you have other suggestions with documentation/examples or know the format that needs to be set I am entirely open to switching.

EDIT

I may have had Easting/Northing backwards to begin with, I remember updating the code shortly after posting (sorry about any confusing) but I believe they are correct now.

I have updated my code such that

    public class Conversion
    {
         // 00663563 01495728 3402
         public static void main(String[] args) 
         {
               double meters =  .3048;
               double lat = 00663563.0 * meters;
               double lon = 01495728.0 * meters;


               Projection nad27= ProjectionFactory.getNamedPROJ4CoordinateSystem("nad27:3402");
               Point2D.Double p_nad27= new Point2D.Double(lon, lat);
               Point2D.Double test      = new Point2D.Double(0, 0);

               nad27.inverseTransform(p_nad27, test);

               System.out.println("Longitude: " + test.getX() + "\nLatitude: " + test.getY());
               System.out.println(nad27.getPROJ4Description());

      } 
  } 

Which now outputs

   Longitude: -84.29503354393064
   Latitude: 39.80814993524988
   +proj=lcc +a=6378249.145 +es=0.006803481196021999 +lon_0=-82d30 +lat_0=38d00 +x_0=609601.2192024384 +y_0=0.0

I guess I should've assumed the information given would be in US feet, and the program requires meters, however this seem to have fixed the problem.

  • You appear to have mixed up north and east in your manual conversion. – whuber Mar 26 '14 at 17:13
  • 2835 is NAD83 Ohio S (meters). The NAD27 version is 32023 (in US feet). 3402 is the "FIPS" code for the zone. The +proj line has the wrong ellipsoid and is missing the lat_1 (38.733333333333) and lat_2 (40.033333333333) parameters as well. Try changing the getNamedPROJ4CoordinateSystem parameter to "epsg:32023" instead. – mkennedy Mar 26 '14 at 19:01
  • I tried using the epsg:32023 last night, and just now and it output (incorrect) information, I can get the output again if you would like to see. As for the +proj line, that is defined in the library, and has not be touched by me. I can't say that it is correct or wrong.. I can attempt to define my own if you don't feel the information is 'exact' or 'correct' enough for suitable use, but you would know better than me. – fisherml Mar 27 '14 at 1:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.