how to Convert Lat ,long to an XY coordinate system (e.g. UTM) and then map this to pixel space of my Image
Asked Answered
B

1

8

I have a very small area map , which I downloaded from Openstreet map(PNG) and also its OSM(.osm) file which contains its Lat ,long.

Now I want to convert Lat ,long to an XY coordinate system (e.g. UTM) and then map this to pixel space of my Image which is of size (600 x 800 ). I know its a two way process ,like to know how to do this . Thank you

Bellman answered 30/5, 2011 at 4:45 Comment(0)
C
8

GPS Coordinates to Pixels

  • Assuming this map does not cross prime meridian
  • Assuming pixel 0,0 is upper left, and pixel 600,800 is lower right.
  • Assuming map is Northern Hemisphere Only (no part of map is southern hemisphere)

    1. Determine the left-most longitude in your 800x600 image (X)
    2. Determine the east-most longitude in your 800x600 image (Y)
    3. Determine Longitude-Diff (Z = Y - X)
    4. Determine north-most latitude in your 800x600 image (A)
    5. Determine south-most latitude in your 800x600 image (B)
    6. Determine Longitude-Diff (C = A - B)

Given a Latitude and Longitude, to determine which pixel they clicked on:

  1. J = Input Longitude
  2. K = Input Latitude

  3. Calculate X-pixel

    XPixel = CInt(((Y - J) / CDbl(Z)) * 800)

  4. Calculate Y-pixel

    YPixel = CInt(((A - K) / CDbl(C)) * 600)

UTM

Here is a cartographic library that should help with GPS to UTM conversions

Cruzcruzado answered 30/5, 2011 at 4:54 Comment(5)
thanks for answer ..Similar to what you said above I already converted my Lat ,Long to Image X and Y . But if you see my question ,first thing is how to convert the Lat,Long to real world X,Y( UTM ) and then Map that to my image X,y ... Because I do certain processing using UTM(x,y).Bellman
See this cartographic projection library for help with the conversion to UTM. Sorry I misunderstood your question. trac.osgeo.org/proj I don't know a solution for going to UTM then to pixelsCruzcruzado
Looks interesting, but costs $$ eye4software.com/products/gpstoolkit/source/vcnet/utmCruzcruzado
here what are the steps 3 and 4 . ? ie CInt,CDbl ??Stanch
CInt converts the inner value into an integer, CDbl converts the inner value to a double-precision floating pointCruzcruzado

© 2022 - 2024 — McMap. All rights reserved.