How to create a mask on a map in lat-lon coordinates?

14 views (last 30 days)
I want to produce a mask on the region shown in figure (map_mask.fig).
I have a lon x lat grid of size 1440x121.
It represents the northen hemisphere with latitude [60,90]N and longitude [-180,180]W at 1/4 degree resolution.
I tried to use poly2mask with the freehand object I wanted as a mask. I got an empty matrix with only 0s.
%Load var: latitude, longitude, latMat, lonMat
load('data.mat')
%unsuccessful attempt
roi = drawfreehand;
Mask = poly2mask(roi.Position(:,1),roi.Position(:,2),1440,121);
%Plot domain
figure(1);
hold on;
axesm('MapProjection','eqdazim','MapLatLimit',[60 90]);
axis off;
framem on;
gridm on;
mlabel on;
plabel on;
setm(gca,'MLabelParallel',0);
geoshow('landareas.shp','FaceColor',"none",'LineWidth',1);
axis off;
set(gca,'Fontsize',15);
gcf;
Thank you

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by