I'm struggling to plot data over dateline when centred on the North Pacific using geoscatter.

15 Ansichten (letzte 30 Tage)
Below is some example data and code. I am wanting to use geoscatter to plot the data across the North Pacific, however it cuts off the data at the dateline (180W Figure 2) due to the way the figure is centered. Geobubble does not cut the data off in the same way and centers the plot around the data (the North Pacific see figure 1). How can I achieve this same behaviour seen in Geobubble (figure 1) in Geoscatter (figure 2)? Thanks for any help!
load example.mat
latlim = [30 75];
lonlim = [130 -115];
centre_lat=54.412;
centre_lon=-173.603;
figure
geobubble(tow_data(:,1),tow_data(:,2),tow_data(:,3));%HOW COME GEOBUBBLE ZOOMS IN BEAUTIFULLY??? Figure 1:
figure
geoscatter(tow_data(:,1),tow_data(:,2),50,tow_data(:,3),'filled');%GEOSCATTER doesn't do well going over -180 line : (
geolimits(latlim,lonlim);
colorbar %Figure 2:

Akzeptierte Antwort

Kevin Holly
Kevin Holly am 7 Jun. 2023
Bearbeitet: Kevin Holly am 7 Jun. 2023
load example.mat
As you can see below, the data points are far apart.
figure
geoscatter(tow_data(:,1),tow_data(:,2),50,tow_data(:,3),'filled');
I added 360 degrees to all the datapoints that were negative.
figure
tow_data(tow_data(:,2)<0,2)=tow_data(tow_data(:,2)<0,2)+360;
geoscatter(tow_data(:,1),tow_data(:,2),50,tow_data(:,3),'filled');
colorbar
Alternatively, you could subtract 360 degrees from all of the longitudinal coordinates greater than zero.
figure
tow_data(tow_data(:,2)>0,2)=tow_data(tow_data(:,2)>0,2)-360;
geoscatter(tow_data(:,1),tow_data(:,2),50,tow_data(:,3),'filled');
colorbar
  1 Kommentar
Clare Ostle
Clare Ostle am 8 Jun. 2023
Thank you that is a useful workaround and helpful. I am still curious that the behaviour of geobubble seems to re-organise the data in the way that you have suggested, whereas geoscatter does not. Do you know why this might be?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Geographic Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by