Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion Issue between WGS84-4326 to NAD27-3069 #13

Open
HaotianShi opened this issue Mar 22, 2019 · 0 comments
Open

Conversion Issue between WGS84-4326 to NAD27-3069 #13

HaotianShi opened this issue Mar 22, 2019 · 0 comments

Comments

@HaotianShi
Copy link

We encountered a conversion issue from WGS84-4326 to NAD27-3069 while doing a project.

We used two ways for projection based on the same longitude and latitude:
A: ESRI ArcMap Projection (using ArcGIS Project tool)
B: Proj4j javacode EPSG geoCode

However, there are some differences between the data (projected x and y of NAD27-3069) obtained by the two methods, which is not reasonable. The x coordinate difference of the same point is around 7-10 meters and the difference of y is about 1-2m, as shown in the table below.

LON |LAT | A.NAD27_X | B.NAD27_X | A.NAD27_Y | B. NAD27_Y
-88.5228 | 42.57655 | 621238.4835 | 621229.7628 | 214633.296 | 214635.8638
-92.2959 | 44.53028 | 317580.3702 | 317565.4482 | 433121.7068 | 433119.4047
-87.9028 | 42.7361 | 671687.3028 | 671680.2527 | 233424.7366 | 233427.5733
-88.5282 | 42.57733 | 620795.31 | 620786.5774 | 214712.7471 | 214715.3176
-88.6028 | 44.03688 | 611961.6631 | 611952.165 | 376702.9819 | 376701.8832
-88.4651 | 44.29296 | 622464.2818 | 622455.3098 | 405342.0929 | 405341.2876
-88.2424 | 44.30755 | 640197.7963 | 640188.9205 | 407318.7782 | 407318.1713
-90.7711 | 43.56154 | 437733.8693 | 437722.7151 | 323251.3754 | 323249.4127
-88.0876 | 43.00795 | 655871.2693 | 655863.4741 | 263254.573 | 263256.7669

How can we address this issue? Thank you!

Here is the java code of Method B:
package Projection;

import java.io.IOException;
import java.net.UnknownHostException;
import java.sql.*;
import java.util.ArrayList;
import java.util.Arrays;
import Projection.db.ConnectionBean;
import org.osgeo.proj4j.CRSFactory;
import org.osgeo.proj4j.CoordinateReferenceSystem;
import org.osgeo.proj4j.CoordinateTransform;
import org.osgeo.proj4j.CoordinateTransformFactory;
import org.osgeo.proj4j.ProjCoordinate;

public class Main {

public static void main(String[] args) throws SQLException, UnknownHostException, IOException {
CRSFactory csFactory = new CRSFactory();
CoordinateTransformFactory txFactory = new CoordinateTransformFactory();
CoordinateReferenceSystem from1 = csFactory.createFromName("EPSG:4326");
CoordinateReferenceSystem to1 = csFactory.createFromName("EPSG:3069");
//CoordinateReferenceSystem from2 = csFactory.createFromName("EPSG:4152");
//CoordinateReferenceSystem to2 = csFactory.createFromName("EPSG:3069");
CoordinateTransform tx1 = txFactory.createTransform(from1, to1);
//CoordinateTransform tx2 = txFactory.createTransform(from2, to2);
long startTime = System.nanoTime();
//connect to database
ConnectionBean con = new ConnectionBean();
PreparedStatement statement = null;
ResultSet resultSet = null;
try
{
String loadSql = "select XXX,LON,LAT,GIS_X,GIS_Y,NAD27_X, NAD27_Y "+
"from xxxxx";

	 statement = con.prepareStatement(loadSql);
     resultSet = statement.executeQuery();
    
  while (resultSet.next())
  {  
	// find empty NAD27 coords 
	if (resultSet.getDouble("NAD27_X") <1 || resultSet.getDouble("NAD27_Y") < 1) {
		
		if (resultSet.getDouble("lon") >0 || resultSet.getDouble("lat") > 0 ) {
			// projection from lonlat to nad27
		    double raw_lon = resultSet.getDouble("lon"); 
			double raw_lat = resultSet.getDouble("lat");
			double ACCDNMBR = resultSet.getDouble("ACCDNMBR");
			ProjCoordinate p1 = new ProjCoordinate(raw_lon, raw_lat);
			tx1.transform(p1, p1);
			//tx2.transform(p1, p1);
			double NAD27_x = p1.x;
			double NAD27_y = p1.y;
			//upadate nad27
			String loadSq2 = "update XXXX set NAD27_X ="+ NAD27_x + ", NAD27_Y = " + NAD27_y + " where XXX =" + XXX;
			statement = con.prepareStatement(loadSq2);
	        statement.executeQuery();
	        statement.close();
		}		
	 }			
   }
  con.commit();
  long endTime   = System.nanoTime();
  long totalTime = endTime - startTime;
  System.out.println(totalTime);
}

catch (SQLException e)
{ 
	System.out.println(e);
}  
finally {
    //System.out.print("finally");
	statement.close();
	con.close();

}

}
}

Thank you very much!

Timothy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant