title: Raster grid position/coordinates of pixel(s) matching a value in R
body: <p>Is there a way to extract the grid position or (preferably for rasters with an explicit extent) point/centroid coordinates of the pixels that match a particular value?  I nearly have a pretty inefficient workflow converting to matrix and using <code>which(mtrx == max(mtrx), arr.ind = TRUE)</code> to get the matrix position(s), but this (a) loses geospatial information and (b) causes data to rotate 90 degrees in the matrix conversion process, both of which requiring extra code to make it work and slow the computations significantly.  Is there an equivalent raster workflow anyone is aware of?</p>