Often a set of data contains unwanted data mixed in with the desired values. For example, your data might include vectors covering the entire United States, but you only want to work with those falling in Alabama. Sometimes a data set contains noise—perhaps three or four points out of several thousand are obvious errors (for example, one of your city points is in the middle of the ocean). In such cases, locating outliers and errors in the data arrays can be quite tedious.
filterm command uses a data grid to filter a vector data set.
Its calling sequence is as follows:
[flats,flons] = filterm(lats,lons,grid,refvector,allowed)
Each location defined by
lons is mapped
to a cell in
grid, and the value of that grid cell is obtained. If
that value is found in
allowed, that point is output to
flons. Otherwise, the point is
The grid might encode political units, and the allowed values might be the code or
codes indexing certain states or countries (e.g., Alabama). The grid might also be
real-valued (e.g., terrain elevations), although it could be awkward to specify all the
values allowed. More often, logical or relational operators give better results for such
grids, enabling the allowed value to be
true). For example, you could use this transformation of the
[flats,flons] = filterm(lats,lons,double(topo>0),topolegend,1)
The output would be those points in
lons that occupy dry land (mostly because some water bodies are
above sea level).