title: Is it possible to perform morphological operations (opening, closing, etc.) on raster data in r?
body: <p>I am currently perform several progressive morphological operations (erosion, dilation, opening, closing) on a image using the <code>mmand</code> package.
  Because this package only works with a matrix, I previously converted my raster with a spatial reference system (geoTIFF) to a matrix. </p>
  
  <p>The Problem: within the conversion I lost the spatial information.</p>
  
  <p>My question: Is there a possibility to perform morphological operations on a raster and to keep the reference system? Or is it somehow possible to keep the reference system after converting the raster to a matrix?</p>
  
  <p>Any suggestions how to solve this problem?</p>