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
Results 1 to 10 of 10

Convert Lat Lon to X Y

This is a discussion on Convert Lat Lon to X Y within the MapPoint Desktop Discussion forums, part of the Map Forums category; I'm drawing shapes in mappoint and the saving the coordinates (lat\lon) to a file. I then have another program that ...

  1. #1
    Dazzer is offline Senior Member Green Belt
    Join Date
    Sep 2003
    Posts
    103

    Convert Lat Lon to X Y

    I'm drawing shapes in mappoint and the saving the coordinates (lat\lon) to a file.

    I then have another program that needs to be able to read these files in and plot the shape on a VB .net form using GDI+ (Not mappoint)

    The problem i'm having is converting these lat lon coordinates into x y pixel coordinates.

    Does anyone have any ideas? The shape needs to re-size with the form.

  2. #2
    manav is offline Junior Member White Belt
    Join Date
    Apr 2006
    Posts
    5

    Ya there has been method given by mappoint to convert

    Hi

    There is a way to convert the lat long to the xy coordinates.

    Once you converted your lat longs to xy then you can easily redraw then again

    The method for converting the is present in render services of mappoint

    RenderService.ConvertToPoint()

    This method takes few arguments as below :
    1. waypoint of the map generated
    2. view array of the map
    3. your picture box's width
    4. your picture box's height

    now with there values you can get the x y coordinates. this is help ful as when the picture box size is changes then it takes the fresh height and width

    Regards

    Manav

  3. #3
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60
    It sounds like Manav's answer is for the MapPoint Web Service, but this is forum is mainly for Desktop MapPoint.
    You need to create a Location object from the longitude,latitude coords and then use the LocationToX() and LocationToY() methods. See the MapPoint documentation for full details, but here's the example from the help file:

    Code:
        Dim objApp As New MapPoint.Application
        Dim objMap As MapPoint.Map
        Dim objLocNY As MapPoint.Location
        Dim objLocLA As MapPoint.Location
        Dim objCenter As MapPoint.Location
        Dim objTextbox As MapPoint.Shape
    
        'Set up application and create Location objects
        Let objApp.Visible = True
        Let objApp.UserControl = True
        Set objMap = objApp.ActiveMap
        Set objLocNY = objMap.FindResults("New York, NY").Item(1)
        Set objLocLA = objMap.FindResults("Los Angeles, CA").Item(1)
    
        'Find the point on the screen midway between the two
        X1% = objMap.LocationToX(objLocNY)
        Y1% = objMap.LocationToY(objLocNY)
        X2% = objMap.LocationToX(objLocLA)
        Y2% = objMap.LocationToY(objLocLA)

    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  4. #4
    Dazzer is offline Senior Member Green Belt
    Join Date
    Sep 2003
    Posts
    103
    Yeah thats not really what I'm trying to.

    I have an app that uses mappoint, the user draws a shape and submits that shape to a database, the shape is stored as a set of lat lon coordinates.

    I have a second app that doesn't use mappoint (and cant) on which I need to plot the shape on a windows form using GDI. The difficulty I'm having is plotting the lat lon coordinates using GDI points.

    The question I was asking was how do I convert these Lat lon coordinates into Pixel X Y coordinates without using mappoint.

    In summary I need to convert a set of lat lon coordinates into Pixel X Y coordinates to plot a shape on a windows form (or possibly change the scale on the form using GDI however being a GDI novice i;m unsure of how to do this either)

    Thanks for your help

  5. #5
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60
    You need to read about map projections. This is a huge subject unto itself, and there are books dedicated to the subject.

    The good news is that you can do it with "a bit of maths".
    A simplistic projection would be to simply use a linear mapping from longitude,latitude to x,y (eg. x=Longitude+180); y=90-Latitude). This will seriously distort the poles, but gives you an idea of a simple approach. There are literally hundreds of different map projections according to your specific needs.



    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  6. #6
    Dazzer is offline Senior Member Green Belt
    Join Date
    Sep 2003
    Posts
    103
    Thanks for your help, I can see i'm going to have to look into this a bit deeper!

  7. #7
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60
    "Transverse Mercator" is probably a good start.

    I'm sorry I can't be of much help beyond this, but it should help in your web and book searches. Many years ago, I did work with esoteric map projections but these were intended for specialist projections of angular data (equal-angle projections for crystallography, and equal-area projections for structural geology).

    I remember at high school we'd often use an equal area map because relative land areas remained the same. Despite this the map looked distorted - eg. Africa was large, and Northern Europe (and Canada) were squashed.


    Richard
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  8. #8
    Dazzer is offline Senior Member Green Belt
    Join Date
    Sep 2003
    Posts
    103
    Thanks for all your help,

    I've got a good grounding now for my research, I didn't think there would be a simple answer (although I hoped there would!), thanks for pointing me in the right direction.

  9. #9
    Fabio is offline Junior Member White Belt
    Join Date
    Oct 2005
    Posts
    9
    Maybe another simple solution is to hold on the database not only lat & long but also corresponding X & Y on the map.

    Is it right?

  10. #10
    Dazzer is offline Senior Member Green Belt
    Join Date
    Sep 2003
    Posts
    103
    Fabio,

    I agree some sort of variation on your suggestion would have been the best way (Convert Lat Lon to xy when drawing the shape and store that, then use that to scale the shape to the size of the form)

    However the data already exists, there are hundreds of thousands of these shapes so to try to re-plot and resubmit would probably more work than attempted a programatic conversion.

    Incidently after some of the suggestions found here I'm actually quite close to a solution, thanks again for your help.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. which is the transformation that MP use to convert....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 07-02-2008, 02:57 PM
  2. Convert .ptm to .jpg
    By dkirk in forum MapPoint Desktop Discussion
    Replies: 6
    Last Post: 03-03-2005, 07:10 AM
  3. Help: convert VB code to Delphi!
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 10-06-2004, 02:02 PM
  4. Convert to Lat/Long
    By wallacech in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 02-26-2004, 01:37 PM
  5. Convert to Add-In
    By David Kachuck in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 07-06-2003, 04:41 PM

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