Change the aspect ratio of x,y to plot Longitude and Latitude correctly ( I have the conversion needed- need help implementing it)
Show older comments
Hi there,
I am wanting to change my x,y axis to reflect true longitude and latitude scales.
The conversion is: 1 degree of longitude (x-axis) is equal to 111cos(latitude). Latitude being the Y-axis. I need this in order to create a single scalebar rather than 2 seperate ones.
this is the code I have but I do not know how to implement it - any help would be much appreciated!
Many thanks!
load('x_data.mat')
load('y_data.mat')
load('z_data.mat')
h = pcolor(X,Y, Z);
shading interp
%% map personalising
xlabel('Longitude (deg, E)');
ylabel('Latitude (deg, N)')
axis equal
% set axis limits
xlim([30.3 30.45])
ylim([40.7 40.8])
hold on
8 Comments
Jan
on 12 Mar 2019
What does "111cos(latitude)" mean?
Do you want to set the DataAspectRatio of the axes?
Jan
on 12 Mar 2019
I do not understand "111*cos(y-axis (lattitude))". All I can imagine, is that "y-axis" is the Y-axis. Then this is a vector of different values. The cosine is not a linear function, and I do not see, how you want to use it to create "for every degree of longitude". I do not know also, how the Z-axis can be "/111".
I assume this is only a problem of the language. So please try to explain this with example data.
P_L
on 12 Mar 2019
Jan
on 13 Mar 2019
You are welcome. This is a forum for solving problems in Matlab, so your questions are perfectly matching the purpose of this forum. :-)
Do you want to use the same scaling factor for the complete X and Y axes, or do you want to transform the data, such that the varying latitude is considered for all coordinates?
If you have tried some functions, please post the code and explain, what "not got it to work" explicitly means.
A small example of the inputs and the wanted output, e.g. drawn by hand, would be useful. Remember, that it does not matter for the actual problem, if the data are coordinates or stock prizes of bananas. The physical meaning of the values has no influence to the solution in Matlab, but it matters, in which format the inputs are stored.
Please read How to ask a good question
P_L
on 13 Mar 2019
Jan
on 13 Mar 2019
@P_L: Please take into account, that I cannot read the code on your screen, if you do not post it here.
"Axesm - I can't get to project properly and display all the ticks- I have just been trying this just in 2D and world map doesn't dispaly anything evewn if I use pcolorm."
I cannot follow this description. Your code contains two calles of axesm, but they are commented - which one are you talkinh of.
"I will be using cellfun to plot data as well."
Why? Is this a part of the question?
"I initially tried plottinmg onto a map that I couldn't get to work for eveything"
Then please post the code and the error message, or a detailed description of the difference between your expectation and the results.
I have also tried xyz2ell.m from https://uk.mathworks.com/matlabcentral/fileexchange/15285-geodetic-toolbox?focused=6513492&tab=function but still not working.
"Still not working" does not allow to give you any advice how to fix the code.
P_L
on 13 Mar 2019
Accepted Answer
More Answers (0)
Categories
Find more on Geographic Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!