Question

For a project we have created an SVG map of certain regions in a province in the Netherlands. On this region we want to show certain points of interests of which we have longitude/latitude coordinates (in decimals).

My question is as follows: how do we calculate the x/y coordinates of a POI given the longitude/latitude, if we are only interested in a certain region?

We are only interested in mapping values from a certain range (longitude is between 51.39 and 51.52, latitude is between 5.4 and 5.6) to a specific map size (675x350 pixels).

Note I have found the following question: Converting Longitude & Latitude to X Y on a map with an answer here but this assumes we want to show the whole world.

Était-ce utile?

La solution

You may not have fully understood https://stackoverflow.com/a/1369568/2375207 answer.

Define your North-West corner of the location on map: 51.5 °N, 5.4 °E This corresponds to the top-left corner of the picture, let's say x=0, y=0

Similarly with the South-East corner: 51.39 °N, 5.6 °E x=675, y=350

And just cross-multiplicate using the boundaries:

675 pixels <-> 5.6 - 5.4 = 0.2° longitude 350 pixels <-> 51.52 - 51.39 = 0.13° latitude

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top