NADCON is a datum conversion method developed by the NGS (National Geodetic Survey), which is used in the United States to convert coordinates between the North American Datum of 1927 (NAD27) and the North American Datum of 1983 (NAD83) with high precision (12-18 cm).
NADCON can also be used in Puerto Rico, American Samoa and the Virgin Islands. To get the actual datum shift for a coordinate, the 4 closest known coordinates (nearest neighbours) are retrieved from a grid file, and then interpolated using bi-linear interpolation.
To read more on how NADCON works, and which files are required, please read our NADCON information page.
The Eye4Software GPS toolkit for Java allows software developers to add coordinate conversion functionality to their programs or applets. Using the GPS toolkit, it is not required to have any knowledge on math, geodesy and map projection formulas.
The product can be used to develop software for many operating systems, including: Linux, Windows, Solaris and Android. But also web oriented platforms by using Java Applets.
The Eye4Software GPS Toolkit for Java can be used to perform map datum conversions using correction grids like NADCON, HARN/HPGN and NTv2. This page explains how to use NADCON with the Eye4Software GPS Toolkit and Java.
In order to develop GPS software using the GPS Toolkit and Java, you have to download and install the Java Developer Kit (JDK) from Oracle. The next step is to install a code editor. It is very well possible to develop Java applications from the command line interface (CLI), however, we strongly suggest to download a (free) Java IDE such as Eclipse or Netbeans. Finally, you have to download and install the Eye4Software GPS toolkit for Java.
Add the following import statement on top of the code that will be using the GPS Toolkit classes and interfaces:
import GpsToolkit.*;
In your class, add the following code to declare the GPS Toolkit interfaces:
IGpsDatumParameters objDatumSrc; IGpsDatumParameters objDatumDst; IGpsGridParameters objGridSrc; IGpsGridParameters objGridDst; IGpsGridParameters objProjection;
And the following code to create an instance of the objects (for instance in the constructor of your class):
IGpsDatumParameters objSrcDatum = new GpsDatumParameters (); IGpsDatumParameters objDstDatum = new GpsDatumParameters (); IGpsGridParameters objSrcGrid = new GpsGridParameters (); IGpsGridParameters objDstGrid = new GpsGridParameters (); IGpsProjection objProjection = new GpsProjection ();
To run this example, all you have to do is copy and paste the Java code below to an empty text file, and change the extension to ".java". You can now execute it from the Windows Command Prompt with the following command:
java -classpath <path to GpsToolkit.jar> <name of Java Class>
The following code shows how to convert geographic latitude-longitude coordinates from NAD83 (North American Datum 1983) to NAD27 (North American Datum 1927). Make sure the GPS toolkit has been installed before running the code sample. Also to adjust the path to the NADCON file.
// ConvNadcon Java demo - Eye4Software GPS Toolkit for Java
// This demo shows how to convert a latitude/longitude coordinate
// from one map datum (NAD83) to another (NAD27) using NADCON.
// For more information on how to use the Eye4Software GPS Toolkit with VBScript,
// visit http://www.eye4software.com/products/gpstoolkitjava/source
package Samples;
import GpsToolkit.*;
public class ConvNadcon
{
public static void main(String[] args)
{
IGpsProjection objProjection = new GpsProjection ();
IGpsDatumParameters objSrcDatum = new GpsDatumParameters ();
IGpsDatumParameters objDstDatum = new GpsDatumParameters ();
// Set Source Datum ( WGS84 )
// The ID for WGS84 is 4326, see 'http://www.eye4software.com/resources/datums' for a full list of supported datums
// To convert from another datum, just change the code below (EPSG code)
// To define your own datum, please have a look at the 'ConvUserGrid' Java demo.
objSrcDatum.LoadFromId(4326);
// Set Destination Datum ( NAD27 )
// The ID for NAD27 is 4267, see 'http://www.eye4software.com/resources/datums' for a full list of supported datums
// To convert to another datum, just change the code below (EPSG code)
// To define your own datum, please have a look at the 'ConvUserGrid' Java demo.
// Using the 'GridType' and 'GridFile' properties, we modify this datum to use NADCON conversion
objDstDatum.LoadFromId(4267);
objDstDatum.set_GridType ( IGpsConstants.GPS_GRIDTYPE_NADCON );
objDstDatum.set_GridFile ( "C:\\Program Files (x86)\\Eye4Software\\GpsToolkit\\Nadcon\\conus.los" );
// Set source latitude and longitude coordinates
objProjection.set_Latitude ( 33.59 );
objProjection.set_Longitude ( -112.15 );
System.out.println( "Converting coordinates from NAD83 to NAD27 Conus (NADCON)");
try
{
objProjection.TransformDatum ( objSrcDatum, objDstDatum );
System.out.format ("(WGS84) 33.590 N, 112.15 W => (NAD27 CONUS) %3.6f N, %3.6f W\n",
objProjection.get_Latitude(), objProjection.get_Longitude () );
}
catch (GpsException e)
{
System.out.println( "An error occured during conversion: " + e.get_ErrorDescription() );
}
System.out.println ( "Ready." );
}
}