Convert latitude / longitude to Pixel coordinates on an arbitrary Mercator map projection

I'm aware this question has been asked in other forms, but I haven't been able to use a solution that works. I want to plot the X, Y coordinates on a Mercator map. The map can be the world map, or a country level map (e.g. US). The maps bounding lat / long can be different depending on what area I'm considering. In my world map I'm chopping off Antarctica and my map isn't a perfect square. The posts I've found assume the map bounds or use Google maps related calculations which are not useful for me. I am NOT using google map images - I have other Mercator vector map sources (MapBox TileMill export is one source) Does anyone have a clean algorithm or C# code I could use / look at, that would be hugely helpful. I did try the algorithm posted here is really nice, except that it only assumes a standard, full size Mercator and won't work on cropped maps. I'm not smart enough to figure out how to compute the offsets :( If you want accurate results for arbitrary projections, mercator or otherwise, the PROJ4 library is a possible solution. You would provide PROJ4's API with the characteristics of your desired, output Mercator map when you initialize it. The link gives you an example of going from lat/long to Mercator with a latitude of true scale of 33 degrees and a Clarke 1866 ellipsoid. You can get precise results with other initialization parameters. Source.

Яндекс.Метрика Рейтинг Free Web Counter
page counter
Last Modified: April 22, 2016 @ 5:03 am