How can I remove those contour lines outside the map?
2 次查看(过去 30 天)
显示 更早的评论
Hello everyone.
Using the code below, I can plot contour lines outlining frost depth values across the Minnesota. As can be seen in the output figures, some contour lines are shown outside the Minnesota map. Would you please help me solve this issue? Indeed, I just want to have contour lines within the Minnesota state.
clear
close all
clc
load("saved_data.mat")
[lon,lat] = meshgrid(-97.24:0.1:-89.48,43.49:0.1:49.38);
for v = 1:(size(data, 2)-2)
figure
usamap("Minnesota")
states=readgeotable("usastatehi.shp");
row=states.Name=="Minnesota";
Minnesota=states(row,:);
geoshow(Minnesota)
textm(Minnesota.LabelLat,Minnesota.LabelLon,Minnesota.Name,"HorizontalAlignment","center")
I = scatteredInterpolant(data(:,[2 1]), data(:,v+2));
I.Method='linear';
I.ExtrapolationMethod='linear';
contourm(lat,lon,min(1,max(0,I(lon,lat))));
colorbar('Ticks',[0.1, 0.3, 0.5, 0.7, 0.9, 1], 'TickLabels',{'0.1','0.3','0.5','0.7','0.9','1'})
end
0 个评论
回答(1 个)
Image Analyst
2023-4-3
If you have (x,y) coordinates of the outline of the state, and a list of (x,y) coordinates you want to check, you can use inpolygon.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Contour Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!