Effacer les filtres
Effacer les filtres

How can I remove those contour lines outside the map?

2 vues (au cours des 30 derniers jours)
Behrooz Daneshian
Behrooz Daneshian le 3 Avr 2023
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

Réponses (1)

Image Analyst
Image Analyst le 3 Avr 2023
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.

Catégories

En savoir plus sur Contour Plots dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by