What is the distance between two locations?
There are many scripts and functions available in the internet to answer that question, including the MatLab own mapping toolbox and the m_map toolbox.
But for mapping many data points in a reasonable small area (less than 1000km diameter) there is a very fast approximation:
lat_vec is a vector of location latitudes and lon_vec the respective longitudes. The distance in meters between all those locations and a center point clat, clon can be written as:
distances = sqrt( ...
(lat_vec - clat).^2 + ...
((lon_vec - clon) .* (cosd(lat_vec)+cosd(clat)./2)).^2 ...
) .* 110000;
this assumes are small scale Cartesian grid, thus the distances are not great-circle distances. The error on scales < 2000km should be small, thus acceptable for data mapping, but not for navigation or similar purposes.
No comments:
Post a Comment