[GIS] Creating a Google Maps GroundOverlay with UTM NAD83 data

google mapsoverlayutm

Edit4: The solution I posted from Jenner at VBforums was, obviously, in VB, and I used an online converter to port it to C#. Something was lost in translations, and that's why it was 10 miles off.

I'm guessing I am just misunderstanding what the algorithms at the Proj.Net discussion boards are for and that's why they weren't doing what I wanted them to.

I will attempt to close this question out in two days when I can mark my answer.


let me preface this by saying I am by no means a GIS expert.

I need to overlay a png image over a Google map. Looking at the v3 api reference, the best way to do this is to use a GroundOverlay, which takes a lat,lng bounds.

I am given one UTM NAD83 coordinate – the NW corner.

I've found UTM to lat,long conversion algorithms online, but they don't even appear to be very accurate. The lat,lng bounds object in the Google API takes two lat,lng points – NE and SW. (Edit: I found a decent way to get the NE and SW points based on the NW point and the size of the image and the provided meters/pixel, so it appears my only problem is the accuracy of the conversion, if you would like to see the solution I used to get the NE,SW points, look here) (Edit2: I'm using .NET and just found Proj.Net; currently looking for good examples for using it).

Edit3, the current problem:
I am having issues converting the UTM to lat and long. A solution I found here a while ago gives me a point about 10 miles south of where I would expect it. A simple mathematical solution I found here, is giving me unexpected results.

double[] inverseMercator (double x, double y) {
     double lon = (x / 20037508.34) * 180;
     double lat = (y / 20037508.34) * 180;

     lat = 180/Math.PI * (2 * Math.Atan(Math.Exp(lat * Math.PI / 180)) - Math.PI / 2);
     return new double[] {lon, lat};
}
double[] toPoint = inverseMercator (686029.702258, 3581213.621173);

I get the following result:

long: 6.1627096689832594

lat: 30.602349476368449

I get similar results using the Proj.Net solution provided by D_Guidi in the same thread.

Using an online converter, I was able to get something closer to what I am expecting:

lat: 32.35238307052292

long: -91.0230710652583

Can anyone shed any light on what I am doing wrong?

I'd prefer to stay away from third party software and just find an algorithm to help me accurately overlay the image with the data I'm given, an example of which I've included below:

2.627469
0.000000
0.000000
-2.627469
686029.702258
3581213.621173
UTM
NAD83
15

First row is meters/pixel

Any help you may be able to provide is certainly appreciated.

Best Answer

The solution I posted from Jenner at VBforums was, obviously, in VB, and I used an online converter to port it to C#. Something was lost in translations, and that's why it was 10 miles off.

I'm guessing I am just misunderstanding what the algorithms at the Proj.Net discussion boards are for and that's why they weren't doing what I wanted them to.