Error in the simultaneous use of contourf and geolimits

조회 수: 2 (최근 30일)
Ivan Mich
Ivan Mich 2022년 8월 1일
편집: Ivan Mich 2022년 8월 28일
I have a problem with my code. I am trying to combine two kinds of maps. the first one is the contour map, and the ather one is the geomap with the geolimit command.
My code is above:
figure(5)
S=shaperead('C:\Users\hp\Desktop\MY_MAP.shp');
lat_grid2=ltln(:,1);
lon_grid2=ltln(:, 2);
Z=ltln(:, 3);
[lon_si, lat_si] = meshgrid(...
linspace(min(lon_grid2),max(lon_grid2)),...
linspace(min(lat_grid2),max(lat_grid2)));
m_alli = griddata(lon_grid2,lat_grid2,Z, lon_rmsi,lat_rmsi,'natural');
contourf(lon_si,lat_si,m_alli,15,'ShowText','on');
mapshow(S,'Color', 'black','LineWidth',2)
set(gca,'ColorScale','log');
colormap(flipud(jet(5)));
colorbar
geolimits([min(lon_grid2) max(lon_grid2)], [min(lat_grid2) max(lat_grid2)])
but command window shows me the error:
Error using geolimits (line 66)
Unable to use geolimits. Current axes or chart is not geographic.
Could you please help me?

채택된 답변

Walter Roberson
Walter Roberson 2022년 8월 1일
use contourm() with 'Fill' option perhaps
contourf() is just contour() with fill, not a different computation
  댓글 수: 12
Walter Roberson
Walter Roberson 2022년 8월 28일
if you are using contourm then you can use scaleruler()
Ivan Mich
Ivan Mich 2022년 8월 28일
편집: Ivan Mich 2022년 8월 28일
I am using these commands:
figure(6)
S=shaperead('C:\Users\hp\Desktop\MY_MAP.shp');
[loni, lati] = meshgrid(...
linspace(min(lon2),max(lon2)),...
linspace(min(lat2),max(lat2)));
mw_alli = griddata(lon2,lat2,Z,loni,lati,'natural');
[c,h]=contourm(lat_rmsi,lon_rmsi,mw_alli,12,'ShowText','on','fill','on');
hold on
geoshow(S,'Color', 'black','LineWidth',2)
colorbar;
scaleruler on
setm(handlem("scaleruler"), ...
"XLoc",21,"YLoc",36.5, ...
"MajorTick",0:200:600, ...
"FontSize",8)
setm(handlem('scaleruler'),'RulerStyle','patches')
But command window shows me:
Error using gcm (line 25)
Not a map axes.
Error in getm (line 80)
gcm(maphndl);
Error in scaleruler>scalerulerOn (line 89)
if strcmp(getm(ax,'mapprojection'),'globe')
Error in scaleruler (line 57)
h = scalerulerOn(s,gca);
which is the mistake? How could I modify my code in order to work?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by