0

This question was asked before on Stack Overflow.

Let's say we have mercator map with given resolution (for simplicity in centimeters).

Now let's get coordinates of (lat,lon) = (50, 15):

$ proj +proj=merc +ellps=WGS84
50 15
5565974.54      1678147.52

Since we don't know the boundaries, we can't scale it to desired resolution.

The only way I've found to get boundaries is compute the coordinates for (lat, lon) = (180, 0) and (0, 90), but that's more like a hack and it's not universal (other projections might map only from (±90, ±90)).

Does proj4 deal with scaling differently?

  • I am confused as to what you are really asking, but from your response to Mintx's answer below, perhaps this post will help with the transformation misunderstanding: stackoverflow.com/questions/2651099/… The accepted answer has a very good breakdown of going from Lat Lon to pixels via Web Mercator. – evv_gis Mar 21 '14 at 13:26
3

I think you may be confusing Mercator XY with the image pixel XY.

The Mercator XYs you are seeing in proj4 are derived from the Mercator formula where the intersection of the Equator and Prime Meridian is 0,0. Those Mercator XYs have nothing to do with the scale of your map.

If you're looking to convert lat/longs to the XY pixel location of an image, see the answer to this question here.

  • I think i'm not confusing them, I want to know how to convert between them! Because mercator is rectangular, there must be some linear transformation from coordinates in mercator and image raster with given resolution. Something like (x,y) = (x0 * scaleX + width/2, y0 * scaleY + height/2). – Robert Mar 21 '14 at 0:57
  • 1
    Mercator is rectangular, but the UOM isn't consistent across the map. X and Y distance increases as you get closer to the poles. (That's why Greenland looks like it's the size of Africa but it's actually about 1/3 the size of Australia) Edited my answer to point to the formula you may be looking for. – Mintx Mar 24 '14 at 23:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.