OpenStreetMap – Converting Lat/Lon to Pixel-XY on Cropped Map

openstreetmapspherical-geometrywgs84

I have a GPX-Track containing LatLon coordinates based on WGS84. The track should be drawn on a cropped map, and for this, I need the pixel coordinates. The map tiles are from OSM

I'm not quite sure how to do this, but I figured out a way (without implementing it yet, since I don't have the formulars right now).

  1. Convert LatLon to Spherical Mercator which is used by OSM
  2. Linear transformation spherical mercator -> pixel coordinates.
    For step 2., 2 identical points are needed. I guess I can use the map's corner points.

Is there a better way to do this?

Best Answer

Solved the Problem. Code here: http://verbose-mode.de/2013/02/cropped-maps-und-wgs84-koordinaten/

Related Question