title: Transform matrix into points based on projection in R
body: <p>I have a <code>SpatialPolygonsDataFrame</code> that I would like to use as the base map for an <code>igraph</code> plot. I have successfully created my <code>igraph</code> network and merged the locations using the <code>centroids</code> in the <code>SpatialPolygonsDataFrame</code>. I would like to transform my layout coordinates, which is in <code>matrix</code> format, in a way that can be plotted over my base map. </p>
  
  <p>I'm using this code but not getting the correct layout. </p>
  
  <pre><code>long_lat &lt;- SpatialPoints(g_locations, proj4string=CRS("tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +datum=OSGB36 +units=m +no_defs +ellps=airy+towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894"))
  
  transformed_locations &lt;- spTransform(long_lat, CRS('+proj=tmerc')) %&gt;% 
      as.data.frame() %&gt;% 
      as.matrix()
  </code></pre>
  
  <p>My question is, how can I state the correct projection when doing a spatial transformation?</p>
  
  <p>Below is a summary of my <code>SpatialPolygonsDataFrame</code>. You will see that I used the text following <code>proj4string :</code> as my <code>CRC</code> argument.</p>
  
  <blockquote>
    <p>local_authority_shp %>% summary()</p>
  </blockquote>
  
  <pre><code>Object of class SpatialPolygonsDataFrame
  Coordinates:
         min       max
  x 5512.999  655644.8
  y 5337.901 1220301.5
  Is projected: TRUE 
  proj4string :
  [+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000
  +y_0=-100000 +datum=OSGB36 +units=m +no_defs +ellps=airy
  +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894]
  Data attributes:
      objectid        lad17cd             lad17nm             lad17nmw  
   1      :  1   E06000001:  1   Aberdeen City:  1   Abertawe     :  1  
   10     :  1   E06000002:  1   Aberdeenshire:  1   Blaenau Gwent:  1  
   100    :  1   E06000003:  1   Adur         :  1   Bro Morgannwg:  1  
   101    :  1   E06000004:  1   Allerdale    :  1   Caerdydd     :  1  
   102    :  1   E06000005:  1   Amber Valley :  1   Caerffili    :  1  
   103    :  1   E06000006:  1   Angus        :  1   (Other)      : 17  
   (Other):374   (Other)  :374   (Other)      :374   NA's         :358  
       bng_e         bng_n          long              lat       
   126473 :  1   268437 :  2   Min.   :-6.6572   Min.   :49.92  
   199821 :  1   1006584:  1   1st Qu.:-2.5644   1st Qu.:51.46  
   200740 :  1   101094 :  1   Median :-1.3868   Median :52.23  
   212501 :  1   101357 :  1   Mean   :-1.4918   Mean   :52.61  
   226544 :  1   104948 :  1   3rd Qu.:-0.2817   3rd Qu.:53.41  
   227922 :  1   105685 :  1   Max.   : 1.6495   Max.   :60.50  
   (Other):374   (Other):373                                    
     st_areasha          st_lengths      local_authority_shp_centroids
   Min.   :2.904e+06   Min.   :   9250   Length:380                   
   1st Qu.:8.626e+07   1st Qu.:  63953   Class :SpatialPoints         
   Median :2.644e+08   Median : 115284   Mode  :S4                    
   Mean   :6.054e+08   Mean   : 193451                                
   3rd Qu.:6.098e+08   3rd Qu.: 197695                                
   Max.   :2.616e+10   Max.   :5261282  
  </code></pre>