title: plotting spatial points over a raster layer in r
body: <p>I wish to plot a matrix (temp_matrix) after converting it to a raster object (tempMap). Further, I wish to add few points whose latitude and longitude locations are available to me on the same plot window. I have tried few approaches but none seems to work since the points available are specific locations in lat/long while the raster object I am getting has a different extent. Please help me with this issue. Given below is the sample data for the problem.</p>
  
  <pre><code>library(raster)
  temp_matrix&lt;-array(NA,c(11,11))
  temp_matrix[1,]&lt;-c(NA,NA,NA,NA,NA,NA,NA,0,0,-6,-6)
  temp_matrix[2,]&lt;-c(0,0,0,0,NA,NA,1,0,0,0,0)
  temp_matrix[3,]&lt;-c(1,0,0,-1,-1,0,0,0,1,0,0)
  temp_matrix[4,]&lt;-c(1,1,0,0,0,0,-1,-1,0,0,0)
  temp_matrix[5,]&lt;-c(1,NA,NA,NA,NA,-1,-1,-1,0,-1,-1)
  temp_matrix[6,]&lt;-c(NA,NA,NA,NA,NA,NA,-1,-1,-1,0,0)
  temp_matrix[7,]&lt;-c(NA,NA,NA,NA,NA,NA,NA,0,-1,0,0)
  temp_matrix[8,]&lt;-c( NA,NA,NA,NA,NA,NA,NA,0,0,0,-1)
  temp_matrix[9,]&lt;-c(NA,NA,NA,NA,NA,NA,NA,-1,0,0,0)
  temp_matrix[10,]&lt;-c(NA,NA,NA,NA,NA,NA,NA,NA,-1,-1,-2)
  temp_matrix[11,]&lt;-c(NA,NA,NA,NA,NA,NA,NA,NA,-2,-3,-2)
  plot(raster(temp_matrix),axes = FALSE,legend=FALSE)
  tempMap &lt;- raster(temp_matrix)
  
  # plot the points over this raster layer
  point_1&lt;-c(10,10) # should appear on 2nd row from top i.e. over temp_matrix[2,10]
  point_2&lt;-c(9,10)  # should appear on 3rd row from top i.e. over temp_matrix[3,10]
  point_3&lt;-c(1,10)  # should appear on lowermost row i.e.over temp_matrix[11,10]
  </code></pre>