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!