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

17 次查看(过去 30 天)
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:

采纳的回答

Kevin Holly
Kevin Holly 2023-6-7
编辑:Kevin Holly 2023-6-7
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 个评论
Clare Ostle
Clare Ostle 2023-6-8
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?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Geographic Plots 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by