How to remove interpolated data over land? (m_map)
Ältere Kommentare anzeigen
I have the following code. When I plot this, it extrapolates the data over land. So I added in a portion where I set the points over land to NaN in my gridded data. However this is not working. Any help would be much appreciated.
%Extablish Map Properties (Set Extends and Type of Projection)
m_proj('Albers Equal-Area Conic','longitudes',[-75, -55], ... 'latitudes',[42 48],'vertical', 'radius',[-70, 50]);
%Grid the Data
[Lat, Long] = meshgrid(linspace(min(X), max(X)), linspace(min(Y), max(Y))); Grid = griddata(X, Y, Z, Lat, Long);
%Code to determine if a point is on land or ocean
coast = load('coast.mat'); [Z, R] = vec2mtx(coast.lat, coast.long, ... 1, [-90 90], [-90 270], 'filled');
%Loop to remove data from land
for r=1:100 for c=1:100 val = ltln2val(Z, R, Lat (r,c), Long (r,c)); isOcean = val == 2; %Returns 0 for Land and 1 For Ocean if isOcean==0 Grid(r,c)=NaN; else end end end
%Create Contour Plot
m_contourf(Lat, Long, Grid, 10);
%Include the grid in the map
m_grid('xtick',10,'tickdir','out','yaxislocation','right','fontsize',7);
%Add in Better Coastline data from excel
m_line (Longtitude1, Latitude1,'LineWidth', 1, 'color', 'r'); m_line (VarName1, VarName2, 'LineWidth', 1, 'color', 'r');
%Legend for the contour map and label
colormap; v = colorbar;
%Lables for the axes
title ('TS_SimB_1'); xlabel ('Longitude'); ylabel ('Latitude');
1 Kommentar
Chad Greene
am 16 Aug. 2016
Bearbeitet: Chad Greene
am 16 Aug. 2016
Antworten (0)
Kategorien
Mehr zu Map Display finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!