Documentation Center

  • Trial Software
  • Product Updates


Filter latitudes and longitudes based on underlying data grid


[latout,lonout] = filterm(lat,lon,Z,R,allowed)
[latout,lonout,indx] = filterm(lat,lon,Z,R,allowed)


[latout,lonout] = filterm(lat,lon,Z,R,allowed) filters a set of latitudes and longitudes to include only those data points which have a corresponding value in Z equal to allowed. R can be a geographic raster reference object, a referencing vector, or a referencing matrix.

If R is a geographic raster reference object, its RasterSize property must be consistent with size(Z).

If R is a referencing vector, it must be a 1-by-3 with elements:

[cells/degree northern_latitude_limit western_longitude_limit]

If R is a referencing matrix, it must be 3-by-2 and transform raster row and column indices to or from geographic coordinates according to:

[lon lat] = [row col 1] * R

If R is a referencing matrix, it must define a (non-rotational, non-skewed) relationship in which each column of the data grid falls along a meridian and each row falls along a parallel. Nearest-neighbor interpolation is used by default. NaN is returned for points outside the grid limits or for which lat or lon contain NaN. All angles are in units of degrees.

[latout,lonout,indx] = filterm(lat,lon,Z,R,allowed) also returns the indices of the included points.


Filter a random set of 100 geographic points. Use the topo map for starters:

load topo

Then generate 100 random points:

lat = -90+180*rand(100,1);
long = -180+360*rand(100,1);

Make a land map, which is 1 where topo>0 elevation:

land = topo>0;
[newlat,newlong] = filterm(lat,long,land,topolegend,1);

ans =
    15     1    

15 of the 100 random points fall on land.

See Also

| |

Was this topic helpful?