mask the data relating to the contour of the continents

5 views (last 30 days)
Does anyone have a solution to mask the data relating to the contour of the continents of a netcdf file?
  1 Comment
Carlos Batista
Carlos Batista on 11 Jul 2014
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?

Sign in to comment.

Accepted Answer

Chad Greene
Chad Greene on 11 Jul 2014
Perhaps inpolygon will do it?
  2 Comments
Carlos Batista
Carlos Batista on 11 Jul 2014
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 on 11 Jul 2014
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.

Sign in to comment.

More Answers (1)

Chad Greene
Chad Greene on 5 Dec 2014
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!