I have a latitude longitude infos and a certain data. I am tryna do a 2D contour earth map using all of these. But result not right why ?

2 vues (au cours des 30 derniers jours)
Here is my code. But the result map is not right. How can i visualize?
% Load latitude and longitude data
latTable = readtable('C:\Users\gozde\Desktop\sat_lat.xlsx');
lat = latTable.Column2;
longTable = readtable('C:\Users\gozde\Desktop\sat_long.xlsx');
long = longTable.Column3;
% Load your data from the CSV file
mTable = readtable('C:\Users\gozde\Desktop\genel unzip\GENEL\GENELims\BUS_DATA_COMBINED.csv', 'Range', 'L2:N17026');
m = mTable{:,:};
% Calculate the magnitude of vectors
MAG = zeros(size(m, 1), 1);
for i = 1:size(m, 1)
MAG(i) = norm(m(i, :));
end
% Create a 2D map of the Earth
figure;
worldmap world;
load coastlines; % Load coastlines for reference
geoshow(coastlat, coastlon, 'DisplayType', 'line', 'Color', 'black');
% Convert latitude and longitude to double arrays
lat = double(lat);
long = double(long);
% Create regularly spaced x and y values
xq = linspace(min(lat), max(lat), 50);
yq = linspace(min(long), max(long), 50);
[Xq, Yq] = meshgrid(xq, yq);
% Use the scattered interpolant to compute the grid of Z values
F = scatteredInterpolant(lat, long, MAG, 'linear', 'linear');
Zq = F(Xq, Yq);
% Create the contour plot
contourm(Xq, Yq, Zq, 'LineColor', 'black'); % Adjust LineColor as needed
colorbar;
framem on;
gridm on;
mlabel on;
plabel on;
colormap('jet');
Here it is my result.
And i want a result like this
  3 commentaires
Gözde
Gözde le 5 Sep 2023
Modifié(e) : Gözde le 5 Sep 2023
Also It doesn't have to look exactly like the first figure. Something like this works for me. (this is the image my code should look like)

Connectez-vous pour commenter.

Réponses (1)

Voss
Voss le 5 Sep 2023
% some fake data:
N = 17025;
lat = rand(N,1)*180-90;
long = rand(N,1)*360-180;
m = rand(N,4);
% Calculate the magnitude of magnetometer
MAG = zeros(size(m, 1), 1);
for i = 1:size(m, 1)
MAG(i) = norm(m(i, :));
end
% Create a 2D map of the Earth
figure;
worldmap world;
% Create regularly spaced x and y values
xq = linspace(min(lat), max(lat), 50);
yq = linspace(min(long), max(long), 50);
[Xq, Yq] = meshgrid(xq, yq);
% Use the scattered interpolant to compute the grid of Z values
F = scatteredInterpolant(lat, long, MAG, 'linear', 'linear');
Zq = F(Xq, Yq);
% Create the contour plot
contourfm(Xq, Yq, Zq, 'LineColor', 'none');
load coastlines; % Load coastlines for reference
geoshow(coastlat, coastlon, 'DisplayType', 'line', 'Color', 'black');
colorbar;
framem on;
gridm on;
mlabel on;
plabel on;
colormap('jet');

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by