Effacer les filtres
Effacer les filtres

Changing the axes in a figure from geographical coordinates to distance in km

3 vues (au cours des 30 derniers jours)
Matthes Müller
Matthes Müller le 12 Sep 2018
Rouvert : Walter Roberson le 22 Déc 2018
Several lines originate from one given point to different places on Earth, shown here in geographical coordinates.
I want the origin on the axes to be displayed as "0 km" and then scale the axes according to the distance from the origin, which can be easily calculated using
distance(lat1,lon1,lat2,lon2,Earth)
How can I include this in my figure programming?
  6 commentaires
Simon Streit
Simon Streit le 12 Sep 2018
I am sure this is not possible for at least the x-Axis, because 1° in x-direction at the equator in W or E is a lot more distance travelled than 1° close the poles. This is the old problem of mapping a sphere to 2D, it's not possible!
jonas
jonas le 12 Sep 2018
Geomapping is a bit outside of my expertise but I am inclined to agree with Simon. One axis will become non-linear.

Connectez-vous pour commenter.

Réponses (1)

jonas
jonas le 12 Sep 2018
I found your figure in another question and attached it to this answer. You could try something like this:
% Units of lat/lon
openfig('Figure.fig')
% Extract data
h=get(gca,'children')
xdata=get(h,'xdata')
ydata=get(h,'ydata')
% Calculate arclength from the origin
yd=cellfun(@(x,y) distance(x(1),y,x(1),y(1)),xdata,ydata,'uniformoutput',false);
xd=cellfun(@(x,y) distance(x,y(1),x(1),y(1)),xdata,ydata,'uniformoutput',false);
% Paths going west and south set to negative
for i=1:length(xdata)
xd{i}(xdata{i}<xdata{i}(1))=xd{i}(xdata{i}<xdata{i}(1)).*-1;
yd{i}(ydata{i}<ydata{i}(1))=yd{i}(ydata{i}<ydata{i}(1)).*-1;
end
% Units of arclength
figure;hold on
h=cellfun(@plot,xd,yd)
However, combining the two figures in the same axes will be difficult.

Catégories

En savoir plus sur Geographic Plots dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by