I have a openstreetmap image.
left upper corner is lat: 80 lon: -169
and right lower corner is lat:-56 lon: 190
The image has the width: 2618 and the height: 1513
How do I convert given lat/lon-coordinates to the pictures x/y-coordinates?
I tried it by myself, but couldn't figure out how to convert the coordinates.
I hope someone can answer my question.
The question, as asked, is almost nonsensical. The area requested covers almost the entire globe, from 80N 169W to 56S 190E. That leaves out the band pole to pole from 170W to 169W, a disk around the north pole north of 80N, and a larger disk around the south pole south of 56S. There is no single best projection from that large an area of the globe to a screen. See wiki on geographic coordinates and map projections as starting places for general background.
That said, this is a reasonable question if the inputs are reasonable.
For very small areas near the equator, a simple projection is to map latitude to Y and longitude to X. As you move away from the equator, this will introduce a small distortion due to the decrease in the length of the degree of longitude as the latitude approaches either pole. For a large enough area that is not symmetric about the equator, this will make the length of the top edge in miles noticeably different from the bottom edge.
A much better projection would map latitude to Y, but scale longitude by cos(latitude)
to get X. For small enough areas, the scale is nearly constant over the whole figure and can be calculated once and held constant.
The general subject of map projection has many more solutions than the simplest identified here. They vary due to the varying goals of each projection. The choice of projection depends on the intended use, and there is generally no single "best" projection even for specific uses.
For more general conversion into and out of projections, there are perl and python wrappers for PROJ.4. These would let you solve any such problem.
There's sample code on the wiki to convert OpenStreetMap tile system to lat/long and back:
http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames
Good luck!