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.
After the image processing methods, I got the ellipse-shaped mask.
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?