Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Pixels [xy] to Lat/Long and vice Versa

This is a discussion on Pixels [xy] to Lat/Long and vice Versa within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi all I want to select a map and copy the image into a picturebox. I know the four corners ...

  1. #1
    bramu is offline Junior Member Yellow Belt
    Join Date
    Mar 2007
    Posts
    13

    Cool Pixels [xy] to Lat/Long and vice Versa

    Hi all

    I want to select a map and copy the image into a picturebox. I know the four corners of the map's lat/long coordinates. I want to return the Lat/Long coordinates of any point on the picture (for e.g. on click I would like to return the Lat/Long of the pixel clicked)'

    I will also need to pass Lat/Long coordinates to my system and convert these coordinates to pixels and show them on map.

    Any help would be appreciated.

    Thanks
    Bramu

  2. #2
    bramu is offline Junior Member Yellow Belt
    Join Date
    Mar 2007
    Posts
    13

    Re: Pixels [xy] to Lat/Long and vice Versa

    Please help me. I need this algorithm badly

  3. #3
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: Pixels [xy] to Lat/Long and vice Versa

    Hi,

    You can use Copy or CopyMap to copy the map to the clipboard. Then you can copy it to your picture box. You know the coordinates of 4 corners, you also know the width and height of your picturebox, so you can calculate the amount of latitude per pixel and for horizontal the amount of longitude per pixel. You have to recalculate this after every resizing of the box.

    In the Click event you know the x,y coordinates of the mouse cursor, so there you can given on the calculation you did before calculate the real lat + long of the clicked position.

    Back in mappoint you use GetLocation method to find the Location for these coordinates.

  4. #4
    bramu is offline Junior Member Yellow Belt
    Join Date
    Mar 2007
    Posts
    13

    Re: Pixels [xy] to Lat/Long and vice Versa

    The solution you gave me does not work if you have a very large zoomwidth. (e.g. you have all of europe visible)


    bramu

  5. #5
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: Pixels [xy] to Lat/Long and vice Versa

    Hi,

    What exacly does not works with a very high altitude ?

  6. #6
    bramu is offline Junior Member Yellow Belt
    Join Date
    Mar 2007
    Posts
    13

    Re: Pixels [xy] to Lat/Long and vice Versa

    The translation from lat/long to pixels and vice versa.

    To give you an example: I had all europe visible (very high altitude) and when I clicked on Italy (to Zoom to italy) the returned image was not that of italy but another place. If I am at a low altitudes, it works fine. AT low altitudes, wherever I clicked it is ok.

  7. #7
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: Pixels [xy] to Lat/Long and vice Versa

    Hi,

    What was wrong the latitude or the longitude ?

    At high altitudes if you dont calculate a correction the longitude will be wrong. Latitude will always be ritht.

    You have to make a correction because 1 degree lat == 1 degree long only on the equator. If you get away from the equator you have to multiply longitude by the cosinus of the latitude to get the correct position (or is it the sine ?, I'm busy with something else at the moment so I can mistake, but you can try this in seconds).

  8. #8
    bramu is offline Junior Member Yellow Belt
    Join Date
    Mar 2007
    Posts
    13

    Re: Pixels [xy] to Lat/Long and vice Versa

    Thx

    You mean that the latitude is always correct and the long = long * cos(latitude)? am I right?

    Brian

  9. #9
    VC_Man is offline Member Green Belt
    Join Date
    Nov 2006
    Posts
    93

    Re: Pixels [xy] to Lat/Long and vice Versa

    Bramu,


    Why don't you use XYToLocation?

    When a user clicks, you catch the mouseclick eventhandler and get the xy of the mouse and than call XYToLocation method of Map object. This is possible with Mappoint 2006.

  10. #10
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: Pixels [xy] to Lat/Long and vice Versa

    Quote Originally Posted by bramu View Post
    Thx

    You mean that the latitude is always correct and the long = long * cos(latitude)? am I right?

    Brian
    Yes to calculate the distance. And in your case also because you start from pixel.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Converting Lat/Long to x,y Pixels
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 09-08-2004, 05:24 PM
  2. Convert to Lat/Long
    By wallacech in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 02-26-2004, 01:37 PM
  3. Lat. and Long.
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 02-06-2004, 03:09 AM
  4. Lat/Long
    By lgeeck in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 07-01-2003, 10:03 AM
  5. get lat./long.
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 11-19-2002, 06:56 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25