Changing the axes in a figure from geographical coordinates to distance in km
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Matthes Müller
el 12 de Sept. de 2018
Abierta de nuevo: Walter Roberson
el 22 de Dic. de 2018
Several lines originate from one given point to different places on Earth, shown here in geographical coordinates.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/195659/image.png)
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 comentarios
Simon Streit
el 12 de Sept. de 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
el 12 de Sept. de 2018
Geomapping is a bit outside of my expertise but I am inclined to agree with Simon. One axis will become non-linear.
Respuestas (1)
jonas
el 12 de Sept. de 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.
0 comentarios
Ver también
Categorías
Más información sobre Geographic Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!