[GIS] The ratio Pixel distance to geographical distance

bing-mapsdistanceepsggeographywgs84

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. 800×800 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;

end

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

Best Answer

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

http://msdn.microsoft.com/en-us/library/bb259689.aspx

http://msdn.microsoft.com/en-us/library/aa940990.aspx

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.

Related Question