Shift Map in App Designer

조회 수: 8 (최근 30일)
meghannmarie
meghannmarie 2020년 7월 24일
편집: Adam Danz 2020년 7월 28일
In app designer I am trying to shift my world map to be centered over the pacific. The whole point of the map is to use the function drawrectangle so the user can select coordinates with a bounding box. I want to be able to convert map to be centered over the pacific in case the user wants to specify a box crossing the dateline. It seems like app designer limited what I can do with figures. I tried to make a map axis so I could just reproject it, but I cannot figure out how to get the map axis in appdesigner nor do I know if it would work with drawrectangle. Here is what i presently have to draw the map centered over the atlantic (-180 to 180). Any ideas how to change this to center the map and shapefile over the pacific (0 to 360)?
The commented out lines is what i tried to get the map axis into the UIAxis, it didnt work...
% Code that executes after component creation
function startupFcn(app)
d = uiprogressdlg(app.UIFigure,'Title','Setting up parallel pool.',...
'Indeterminate','on');
blue = [180/255 198/255 231/255];
green = [83/255 129/255 53/255];
% figure(app.UIFigure)
% h = axesm('mercator', 'maplonlimit', [0 360]);
% hCopy = copyobj(h.Children, app.UIAxes); % Copy all of the axis' children to your app axis
% delete(h.Parent)
geoshow(app.UIAxes,'landareas.shp', 'FaceColor', green);
app.UIAxes.Color = blue;
xlim(app.UIAxes,[-180 180])
xticks(app.UIAxes,-180:30:180)
xlabel(app.UIAxes,'Longitude')
ylim(app.UIAxes,[-90 90])
yticks(app.UIAxes,-90:15:90)
ylabel(app.UIAxes,'Latitude')
app.UIAxes.XGrid = true;
app.UIAxes.YGrid = true;
app.pool = gcp;
app.ParallelPoolSizeEditField.Value = app.pool.NumWorkers;
close(d)
end

채택된 답변

Adam Danz
Adam Danz 2020년 7월 28일
편집: Adam Danz 2020년 7월 28일
Since the worldmap function does not currently support setting parent axes, you'll have to create the plot in an external figure, make all needed changes, and then copy it to your app's axes. Here are instructions.
To center the plot on the pacific ocean, set the lat and lon limits using worldmap(latlim,lonlim).
map = shaperead('landareas.shp', 'UseGeoCoords',true);
worldmap([-45 80],[0 360]) % approximately centered over the pacific
geoshow(map)
Then copy to your app axes. See this comment below for details.
Then draw rectangle.
h = drawrectangle(app.UIAxes); % supply your axis handle
  댓글 수: 4
meghannmarie
meghannmarie 2020년 7월 28일
Thanks, that is exactly what I was looking for!! I am pretty sure this will work for me.
Adam Danz
Adam Danz 2020년 7월 28일
It was fun to figure it out along with ya.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop uifigure-Based Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by