How can I use scatteredInterpolant function to interpolate between a bunch of scatter points within the map? (without using meshgrid)?)

7 visualizaciones (últimos 30 días)
Hi all,
The output of the following code is 5 contour maps representing the probability that feezing depth across Alaska state exceeds a specific values (each plot corresponds to a specific value) . Actually, these probability values are estimated for each weather station existing in the Alaska state and come from the column 3 to 7 of the attached cell array called "POFDE" . I used scatteredInterpolant function to interpolate probability values all around the map. However, before doing that, I created a mesh as a querry points. This mesh is equivalent to the bounding box for Alaska. Can I define the iregular geometry of the map as queery points so that there would no contour lines outside the map?
The latitude and longitude of the polygones used to plot the map is stored in a struct called "S".
Note: Column 1 and 2 of the POFDE represent latitude and longitude of weather stations.
clear
close all
clc
load('POFDE.mat');
S=shaperead('tl_2018_02_anrc.shp','UseGeoCoords',true);
data = cell2mat(POFDE);
%%%%%%generating mesh as query points based on the Alaska bounding box
X=linspace(-179.148909,-130,1500);
Y=linspace(51.214183,71.365162,1500);
[lon,lat] = meshgrid(X,Y);
%%%%%% ploting contour maps
for i = 1:(size(data, 2)-2)
figure
geoshow(S,"DisplayType","multipoint")
xlim([-179.148909,-130]);
ylim([51.214183,71.365162]);
I = scatteredInterpolant(data(:,[1 2]), data(:,i+2));
I.Method='natural';
I.ExtrapolationMethod='none';
contourm(lat,lon,min(1,max(0,I(lat,lon))))
colorbar
title(['The probability of frost depth exceedance of \Omega_{\delta} = ' num2str(i) ' feet'])
exportgraphics(gca, sprintf('FrostPlot_%d_feet.png', i))
end

Respuestas (1)

Walter Roberson
Walter Roberson el 21 de Feb. de 2023
Yes. Follow the steps I suggested in your previous question to turn the shapes into a a mask. Then find() on the mask to get the locations of the pixels within bounds. index the marginal vectors to get the associated lat and long values. scattered interpolant on those points only.
I would point out that this will be more work than just querying at all of the points in the grid and then setting to nan the points outside the shape. However if the number of query locations within bounds is notably smaller than the bounding box (for example the panhandle is long but narrow) then it might potentially be worth doing.
Note that as yet you have not responded to my previous concern about which data points to use to form the information queried against... my "3 cm East would give nan" remarks.
  1 comentario
Behrooz Daneshian
Behrooz Daneshian el 21 de Feb. de 2023
Thank you for your reply.
Let me clarify more. For each weather station in Alaska state(shown on the attached jpg file), some probabilities have been estimated(column 3 to 7 of the cell array called POFDE). Based on probabilities of these weather stations(blue points of the map), I want to draw contour lines showing locations where have the same probability of freezing.
It should be mentioned that latitude and longitude of stations are stored in column 1 and 2 of the POFDE respectively.
Did I answer your question in a right way?

Iniciar sesión para comentar.

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by