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

**URL:** <https://mapwindow.discourse.group/t/potential-projection-mismatch-help-me-code-jedis/1342>\
**Category:** Uncategorized\
**Created:** [May 17, 2022, 7:43pm UTC](https://mapwindow.discourse.group/t/potential-projection-mismatch-help-me-code-jedis/1342 "2022-05-17T19:43:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericpalmatier](https://avatars.discourse-cdn.com/v4/letter/e/dbc845/32.png) [@ericpalmatier](https://mapwindow.discourse.group/u/ericpalmatier)\
**Post date:** [May 17, 2022, 7:43pm UTC](https://mapwindow.discourse.group/t/potential-projection-mismatch-help-me-code-jedis/1342/1 "2022-05-17T19:43:58Z")

</div>

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.

 ![google_vs_MWG_SitePad_V2_2](https://global.discourse-cdn.com/free1/uploads/mapwindow1/original/1X/0603f660d30fba49b96e61459a4b8157df63ca20.jpeg)

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.

 ![google_vs_MWG_SitePad_V2](https://global.discourse-cdn.com/free1/uploads/mapwindow1/original/1X/243e04a0e314c33437f3df2dd46a847dde40730f.jpeg)

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!

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [May 23, 2022, 6:12am UTC](https://mapwindow.discourse.group/t/potential-projection-mismatch-help-me-code-jedis/1342/2 "2022-05-23T06:12:03Z")

</div>

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](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](https://gdal.org/community/index.html#mailing-list)).

Respectfully.  
Jerry.

---

<div class="post-metadata">

**Author:** ![ericpalmatier](https://avatars.discourse-cdn.com/v4/letter/e/dbc845/32.png) [@ericpalmatier](https://mapwindow.discourse.group/u/ericpalmatier)\
**Post date:** [May 24, 2022, 1:51pm UTC](https://mapwindow.discourse.group/t/potential-projection-mismatch-help-me-code-jedis/1342/3 "2022-05-24T13:51:08Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [May 25, 2022, 6:33pm UTC](https://mapwindow.discourse.group/t/potential-projection-mismatch-help-me-code-jedis/1342/4 "2022-05-25T18:33:02Z")

</div>

Yes, there are a number of GDAL operations exposed through the API. See [HERE](https://www.mapwindow.org/mapwingis/class_gdal_utils.html) and related operations in the help file.

Regards,  
Jerry.

---

<div class="post-metadata">

**Author:** ![ericpalmatier](https://avatars.discourse-cdn.com/v4/letter/e/dbc845/32.png) [@ericpalmatier](https://mapwindow.discourse.group/u/ericpalmatier)\
**Post date:** [May 25, 2022, 8:46pm UTC](https://mapwindow.discourse.group/t/potential-projection-mismatch-help-me-code-jedis/1342/5 "2022-05-25T20:46:44Z")

</div>

Jerry,

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