Latitudes and longitudes of nonzero data grid elements
[lat,lon] = findm(Z,R)
[lat,lon] = findm(latz,lonz,Z)
[lat,lon,val] = findm(...)
mat = findm(...)
[lat,lon] = findm(Z,R) computes the latitudes and
longitudes of the nonzero elements of a regular data grid,
R as a
RasterSize property of
must be consistent with
[lat,lon] = findm(latz,lonz,Z) returns
the latitudes and longitudes of the nonzero elements of a geolocated
Z, which is an M-by-N logical or numeric
M-by-N latitude-longitude arrays, but
be a latitude vector of length M and
lonz may be
a longitude vector of length N.
[lat,lon,val] = findm(...) returns
the values of the nonzero elements of
Z, in addition
to their locations.
mat = findm(...) returns
a single output, where
mat = [lat lon].
This function works in two modes: with a regular data grid and with a geolocated data grid.
The data grid can be the result of a logical operation. For example, load elevation raster data and a geographic cells reference object. Then, find all locations with elevations greater than 5500 meters.
load topo60c [lat,lon] = findm((topo60c > 5500),topo60cR); [lat lon]
ans = 34.5000 79.5000 34.5000 80.5000 30.5000 84.5000 28.5000 86.5000
These points are in the Himalayas. Find the grid values at these locations using the
[row,col] = geographicToDiscrete(topo60cR,lat,lon); indx = sub2ind(size(topo60c),row,col); heights = topo60c(indx)
heights = 5559 5515 5523 5731
Version HistoryIntroduced before R2006a
findm will not accept referencing vectors or referencing matrices as input
findm function will not accept referencing
vectors or referencing matrices as input in a future release. Use a
geographic raster reference object, specified as a
GeographicPostingsReference object, as input
instead. Reference objects have several advantages over referencing
vectors and referencing matrices.
Unlike referencing vectors and referencing matrices, reference objects have properties that document the size of the associated raster, its geographic limits, and the direction of its rows and columns.
You can manipulate the limits of geographic rasters associated with reference objects using the
You can manipulate the size and resolution of geographic rasters associated with reference objects using the
To update your code, create a geographic reference object.
Create a geographic reference object for a raster of cells by using the
Create a geographic reference object for a raster of regularly posted samples by using the
Convert from a referencing vector to a geographic reference object by using the
Convert from a referencing matrix to a geographic reference object by using the
Once you have created a reference object, replace uses of the referencing vector or referencing matrix in your code with the reference object.