I have had this problem for several days and I have no idea to solve it.

The problem is that I am trying to find out the length and width of ships from a Bing map. I got the location point (lon, lat),the image zoom level and also the image size. The following image is an example. 800x800 image at (53.5211,10.0657)with zoomlevel 19.

enter image description here

After the image processing methods, I got the ellipse-shaped mask. enter image description here

I then calculated the pixel distance of major axis = 472.86 and minor axis = 92.58 of the ellipse. The idea is to calculate the ratio of geographical distance divided by pixel distance and to try and get each pixel points and its corresponding geographical location by the conversion from given lat/lon in WGS84 datum to XY in Spherical Mercator EPSG:900913.

I now have two geographical point locations and calculate the distance (d_g) by using haversine formula. Also I have the pixel distance (d_p). Then the ratio is r = d_g/d_p. However,the detected length and width are not close to the real value.

I found the problem is in the conversion from given lat/lon in WGS84 datum to XY in Spherical Mercator EPSG:900913.

This is the function I used to convert.

function [x,y] = latLonToMeters(lon, lat )

% Converts given lat/lon in WGS84 Datum to XY in Spherical Mercator EPSG:900913"

originShift = 2 * pi * 6378137 / 2.0;

x = lon * originShift / 180;

y = log(tan((90 + lat) * pi / 360 )) / (pi / 180);

y = y * originShift / 180;


Is there another way to get the geographical location by given only center point (lon,lat), zoom level and size of image?

  • 1
    You don't want to be using a Mercator projection for distance calculations. Use an equal-area projection instead.
    – Vince
    Commented Sep 14, 2014 at 12:40
  • One more question. There are several equal area projections, which one is better?
    – user10433
    Commented Sep 14, 2014 at 13:30
  • At the scale of the size of a ship, I don't see how it could matter (especially given the error inherent in the pixel size).
    – Vince
    Commented Sep 14, 2014 at 20:15

1 Answer 1


There are two really good article in the Bing Maps documentation around the tiling system and scale/resolution:



Assuming you have, or can get the latlong value of the center of the map, or the center of the ship for more accuracy, you can then calculate the ground resolution in meter's/pixel for that level of latitude. At zoom level 19 a single pixel is approximately 30cm of distance, or 1 foot at the equator. The formula for this is:

ground_resolution = (cos(Latitude * pi/180) * 2 * pi * 6378137) / (256 * 2^zoomLevel)

Once you have this you can get approximate distances by converting your pixel distances to meters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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