title: Converting Raster to Point Shapefile
body: <p>I am trying to convert raster to point shapefiles </p>
  
  <pre><code>&gt; library (raster)
  &gt; ras &lt;- raster("dem.tif")
  &gt; pts = rasterToPoints(ras)
  &gt; pts
                 x         y       Z
     [1,] 70.87500 38.375007  5.035302e+14
     [2,] 71.12500 38.375007  4.563356e+14
     [3,] 70.62500 38.125007  4.987732e+14
     [4,] 70.87500 38.125007  4.108542e+14
     [5,] 71.12500 38.125007  4.114788e+14
     [6,] 70.37500 37.875006  6.538783e+14
     [7,] 70.62500 37.875006  5.798219e+14
     [8,] 70.87500 37.875006  5.045395e+14
     [9,] 71.12500 37.875006  4.315951e+14
  &gt; writeOGR(p, ".", "output_name, driver="ESRI Shapefile")
  Error in writeOGR(p, ".", "filename", driver = "ESRI Shapefile") : 
    inherits(obj, "Spatial") is not TRUE
  &gt; raster::shapefile(pts, "output_name.shp")
  Error in (function (classes, fdef, mtable)  : 
    unable to find an inherited method for function ‘shapefile’ for signature ‘"matrix"’
  &gt; shapefile(p, outfile, overwrite=TRUE)
  Error in (function (classes, fdef, mtable)  : 
    unable to find an inherited method for function ‘shapefile’ for signature ‘"matrix"’
  &gt;plot(pts)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/vJxcT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vJxcT.png" alt="enter image description here"></a>
  Where am i wrong in converting these files into shapefile? </p>