# Potential Projection Mismatch - Help me Code Jedi's!

Hello Everybody (dr. Nick accent / Simpsons)

I am a year in on my project and I seem to have stumbled on to what could be a very severe issue. I am positive it is something I am simply overlooking, but as a scientist (and not the data kind!) I am a bit out of my depth here. I think my coding prowess can be summed up thusly: " even a broken clock is right twice a day"

That being said, Here’s some background.

My software is for mapping raw data counts over a geo-rectified image. pretty simple, probably shouldn’t have taken me a year to get to this point, but here I am. The software allows a user to load an image, typically a screen grab from google maps, but it can be anything really. The user can then geo-rectify it using a subroutine.

I think My worldfiles are right, but I have two questions.

1. If the user is using google maps imagery, but the AXmap1 projection is set to projection_WGS84, will that cause an error when displaying the .JPG/.JGW?

2. If you were mathematically computing the Worldfile, using visual basic, How would YOU do it?
I’ll show you below what I am doing and explain it best I can.

Here is an image that first led me to believe there was an issue with the way my software displays the image.

Here you can see I have drawn an outline around the same image of a building, just overlaid in GIMP and the Opacity adjusted so we can see both at the same time. Clearly there is a bit of a rotation.

Here you can see a similar issue. There seems to be a bit of a rotation and a scaling mismatch.

``````    For j = 2 To 100
If CalCoord(j, 1) = 0 Then
Exit For
End If
If (CalCoord(j, 3) - CalCoord(j - 1, 3)) = 0 Or (CalCoord(j, 4) - CalCoord(j - 1, 4)) = 0 Then
MsgBox("Error: choose wider spaced points", vbOKOnly)
Erase CalCoord
Exit For
End If
If j = 2 Then
LongXperPixel = Math.Abs((CalCoord(j, 1) - CalCoord(j - 1, 1)) / (CalCoord(j, 3) - CalCoord(j - 1, 3)))
LatYperPixel = Math.Abs((CalCoord(j, 2) - CalCoord(j - 1, 2)) / (CalCoord(j, 4) - CalCoord(j - 1, 4)))
Else
' not a true average, fix later
LongXperPixel = (LongXperPixel + Math.Abs((CalCoord(j, 1) - CalCoord(j - 1, 1)) / (CalCoord(j, 3) - CalCoord(j - 1, 3)))) / 2
LatYperPixel = (LatYperPixel + Math.Abs((CalCoord(j, 2) - CalCoord(j - 1, 2)) / (CalCoord(j, 4) - CalCoord(j - 1, 4)))) / 2
End If
Next j
LongXMax = CalCoord(1, 1) - (CalCoord(1, 3) * LongXperPixel)
LatYMaX = CalCoord(1, 2) + (CalCoord(1, 4) * LatYperPixel)
' save to world file
absoluteYPixel = (-(Math.Abs(LatYperPixel)))
absoluteXPixel = (Math.Abs(LongXperPixel))

WorldFileWriter(absoluteXPixel, absoluteYPixel, LongXMax, LatYMaX, mMapFile)

regpts = 1

If MsgBox("World File (.JGW) Generated, Click 'OK' to reload SitePad with new rectified image", 1, "World File Generated Sucessfully!") = vbCancel Then
'the user hits cancel. do nothing...idiots..
Else
HALTandRESTART()
End If
``````

I am really confused. I am somewhere between thinking there is an issue with my projection setup, OR I am goofing something up with my Worldfile math. What I have not been able to do, YET, is find a reliable and free piece of software where I could georeference this image and compare the generated Worldfile with mine. Any suggestions would be welcome!

Hello @ericpalmatier

Although you may find help here related to imagery and world files, I will suggest an alternative. All of the imagery operations in MapWinGIS are performed by an open-source library that we have incorporated, called GDAL (see https://gdal.org/index.html).

You may be better off asking this question on their support forum (https://gdal.org/community/index.html#mailing-list).

Respectfully.
Jerry.

Jerry,

Thanks for the insight, I will look through their literature to see what I can find. As a side question, can I access the GDAL tools through the mapwingis API, or will I have to load the GDAL API separately? thanks!

Yes, there are a number of GDAL operations exposed through the API. See HERE and related operations in the help file.

Regards,
Jerry.

Jerry,

You are an amazing person! Thanks for pointing me in this direction, this is precisely what I needed~~