ThinkGeo.com    |     Blog    |     Wiki    |     Support

Projection system conversions

Does this product provide conversion functions between NAD27 and NAD83 lat/lon values?

Thanks. This is a pre-sales question.

Hi Michael,

I think NAD27 and NAD83 is a group of projections but not be a specified projection, we support conversion between most projections. Our API support epsg id or proj4 string, as below is a simple sample to show how to reprojection:

        ManagedProj4Projection proj4 = new ManagedProj4Projection();
        proj4.InternalProjectionParametersString = ManagedProj4Projection.GetDecimalDegreesParametersString();
        proj4.ExternalProjectionParametersString = "+proj=stere +lat_0=90 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m no_defs";
        proj4.Open();

        PointShape yourPoint = new PointShape();

        PointShape yourPointUnderGoogleProjection = proj4.ConvertToExternalProjection(yourPoint) as PointShape;

Wish that’s helpful.

Regards,

Don

I found this on the proj4 website here: https://github.com/OSGeo/proj.4/wiki/FAQ:

How do I do datum shifts between NAD27 and NAD83?
While the nad2nad program can be used in some cases, the cs2cs is now the preferred mechanism. The following example demonstrates using the default shift parameters for NAD27 to NAD83:
% cs2cs +proj=latlong +datum=NAD27 +to +proj=latlong +datum=NAD83
-117 30
producing:
117d0’2.901"W 30d0’0.407"N 0.000

So the question, more precisely, is can I do this directly from ThinkGeo API’s?

Hi Michael,

Thanks for your page, that’s helpful to understand your question.

Our API focus on convert between two specified projections, I tested based on the page today like this:

  PointShape point = new PointShape(-117, 30);

            UnmanagedProj4Projection proj4 = new UnmanagedProj4Projection();
            proj4.InternalProjectionParametersString = "+proj=longlat +datum=NAD27"; // that's maybe epsg 4267?
            proj4.ExternalProjectionParametersString = "+proj=longlat +datum=NAD83"; // it looks like epsg 4269, but not the same             
            proj4.Open();
            PointShape rPoint = proj4.ConvertToExternalProjection(point) as PointShape;

But it looks the result is incorrect.

The correct value should be like this:

I guess that’s maybe because our wrapper don’t support this conversion type, or maybe that’s because we hadn’t integrated the latest Proj4 version.

I am not sure about your scenario, do you think that’s possible to use two specified projection? If so I think we can get a exact result with our API.

Wish that’s helpful.

Regards,

Don

Michael,

We recreated your issue where the cs2cs tool returns “117d0’2.901"W 30d0’0.407"N 0.000” but ours returns a different result. It might because some datum resource files were missing and we are looking into it.

Ben

Hi Michael,

We did more researching on the FAQ document and missed on environment variable setting config. The document doesn’t clarify this step, so it is very easy to misunderstand.

Now, we don’t need to change our current unmanaged proj4 projection. The only thing we need to do is to unpack my attached file, and set the environment below. Make sure reset your machine after it is set.

Then you could get the correct result with following code.

PointShape point = new PointShape(-117, 30);
UnmanagedProj4Projection proj4 = new UnmanagedProj4Projection();
proj4.InternalProjectionParametersString = “+proj=longlat +datum=NAD27”;
proj4.ExternalProjectionParametersString = “+proj=longlat +datum=NAD83”;
proj4.Open();
PointShape rPoint = proj4.ConvertToExternalProjection(point) as PointShape;

So it might be a workaround for you.

Thanks
Mark

1 Like

Hi Michael,

After deeply researching, the NAD grids relative files is required.

You can download the NAD grids files from (https://ap.thinkgeo.com:5001/sharing/X1vDGoagH) and please extract the “PROJ_LIB.zip” into your application folder (.exe folder), the extracted folder must be renamed to “PROJ_LIB”, such as following folder structure diagram:

Thanks,

Having some issues using Proj4 API’s in TG to convert lat/longs to X,Y coordinates. If there’s a better way to do this, please push me in the right direction, I"m a NOOB.

Code is like this:

Proj4Projection proj4 = new Proj4Projection();
proj4.InternalProjectionParametersString = “+proj=longlat +no_defs”;
proj4.ExternalProjectionParametersString = “+proj=lcc +datum=NAD83 +lon_0=-98 +lat_1=36d46 +lat_2=35d34 +lat_0=35 +x_0=600000 +y_0=0 +to_meter=0.3048006096012192 +no_defs”;
proj4.Open();
Vertex v = proj4.ConvertToExternalProjection(lon, lat);

I have tried changing the culture to Invariant temporarily, but then the conversion API’s return null strings on these.

I have set up an environment variable PROJ_LIB to point to the PROJ_LIB folder which is in the folder that contains my program binary as previously suggested, with the relative nadgrid files unzipped into there.

I get an exception on proj4.Open() code which says:
“Initialize Ellps Failed!”

Would appreciate some assistance getting this worked out. I am essentially attempting to convert lat/longs to X,Y in International Feet.

Thanks in advance for any help.

Hi Michael,

I think the problem is “+proj=longlat +no_defs” don’t works for our projection class.

If that’s LongLat(Decimal Degree), I think it should be “+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs”.

You can use this code, it works well.

            Proj4Projection proj4 = new Proj4Projection();
        proj4.InternalProjectionParametersString = Proj4Projection.GetDecimalDegreesParametersString(); //"+proj=longlat +no_defs";
        proj4.ExternalProjectionParametersString = "+proj=lcc +datum=NAD83 +lon_0=-98 +lat_1=36d46 +lat_2=35d34 +lat_0=35 +x_0=600000 +y_0=0 +to_meter=0.3048006096012192 +no_defs";
        proj4.Open();
        Vertex v = proj4.ConvertToExternalProjection(lon, lat);

Regards,

Ethan

Yes, thank you. Sometimes you just have to be smarter than the tool (!!!)

Yes. This indeed works correctly, now that I’ve been educated. I have checked these calculations against EarthPoint for arbitrary sample data and have been able to precisely duplicate the numbers produced on this website for State Plane projection converting to X, Y.

I learned some additional things:

  • On the EarthPoint site, State Plane is assumed to be NAD83;
  • PROJ4 class returns feet as US Survey feet, NOT INT’L Feet. This makes a difference to us since we support explicit unit options in our UI that include BOTH of these. I should have known this because of the value of the conversion factor that is placed into the PROJ4 strings that are specified to include Feet as the unit.

Thanks, once again, this issue is completely resolved.

Hi Michael,

In fact it looks you are more professional on projection than me, so I also learn something from your summary, thanks for your share.

Any quesiton please feel free to let us know.

Regards,

Ethan