mask the data relating to the contour of the continents

3 次查看(过去 30 天)
Does anyone have a solution to mask the data relating to the contour of the continents of a netcdf file?
  1 个评论
Carlos Batista
Carlos Batista 2014-7-11
I'm having a doubt that the following (...)
I am using netcdf data of sea surface temperature (SST) of the entire globe. I have these file data of SST and the values of the contours of the continents (32767 values).
I write this for this script
NCID netcdf.open = ('anom.sst.nc', 'NC_NOWRITE'); %%%%%%%% LONGITUDE [sst, xtype, varDimIDs, varAtts] = netcdf.inqVar (NCID, 0); varid = netcdf.inqVarID (NCID, sst); Lonn = double (netcdf.getVar (NCID, varid));
%%%%%%%% LATITUDE [sst, xtype, varDimIDs, varAtts] = netcdf.inqVar (NCID, 1); varid = netcdf.inqVarID (NCID, sst); LATN = double (netcdf.getVar (NCID, varid));
%%% time [sst, xtype, varDimIDs, varAtts] = netcdf.inqVar (NCID, 2);
%%% time [sst, xtype, varDimIDs, varAtts] = netcdf.inqVar (NCID, 3);
%%% time [sst, xtype, varDimIDs, varAtts] = netcdf.inqVar (NCID, 4);
varid = netcdf.inqVarID (NCID, sst); % Open my date data = double (netcdf.getVar (NCID, varid));
%%%%%%%%%%%%%%%%%%%% My question is: How to inform pro Matlab does not consider the values of the contours of the continents?

请先登录,再进行评论。

采纳的回答

Chad Greene
Chad Greene 2014-7-11
Perhaps inpolygon will do it?
  2 个评论
Carlos Batista
Carlos Batista 2014-7-11
Thanks Chad for your answer!!
Chad, the inpolygon isn't only for graphics? I need inform in matrix of Matlab that the value 32767 not is considerable!!! How declare for the matlab matrix that an value don't is considerable ??
Thanks again!
Chad Greene
Chad Greene 2014-7-11
Perhaps I misunderstood your question. Here is what I thought:
My assumption was that you have a grid of SST data, a corresponding grid of latitudes, a grid of longitudes, and 32767 points that define the outline of the continents. If this is true, inpolygon should tell you which grid points are inside the outline of the continents.
But I think I misunderstood. If you have a grid where all land values are given the value 32767, set them to NaN by
SST(SST==32767)=NaN;
Then you can plot sea surface temperatures easily with pcolor or pcolorm.

请先登录,再进行评论。

更多回答(1 个)

Chad Greene
Chad Greene 2014-12-5
Another solution is the landmask function on FEX.

Community Treasure Hunt

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

Start Hunting!

Translated by