title: How can I modify and save rnaturalearthdata::countries50 without losing information?
body: <p>I'm new to geographic data. I've opened and modified the SpatialPolygonsDataFrame rnaturalearthdata::countries50. After using st_as_sf() and st_shift_longitude(), it is now a SpatialPointsDataFrame. What is the best way of saving the file so that I don't lose any data compared to what the SpatialPointsDataFrame has attached to it? I read <a href="https://gis.stackexchange.com/questions/162019/how-to-export-a-dataset-with-spatialpolygonsdataframe-as-a-shapefile/337413">this</a> post and there seem to be differences with regards to geographical projections. I'm concerned that if I save it in one way, I will lose irrecoverable information (like when I save a dataframe to a .csv instead of .RData, I will lose the name of the R object).</p>
  <p>Here is what I have considered:</p>
  <pre><code>library(dplyr) # for pipes
  
  mySPDF &lt;- rnaturalearthdata::countries50 %&gt;% 
      st_as_sf() %&gt;%
      st_shift_longitude()
  
  library(sf)
  st_write(mySPDF, &quot;mySPDF.shp&quot;) # error
  </code></pre>
  <pre><code>library(maptools)
  writeSpatialShape(mySPDF, &quot;mySPDF&quot;) # warning: 1: writeSpatialShape is deprecated; use rgdal::writeOGR or sf::st_write 
  </code></pre>
  <p>From the above-cited post:</p>
  <pre><code>library(rgdal)
  
  writeOGR(obj=mySPDF, dsn=&quot;tempdir&quot;, layer=&quot;mySPDF&quot;, driver=&quot;ESRI Shapefile&quot;) # this is in geographical projection
  </code></pre>
  <p>So I'm wondering how can I save/export my SpatialPointsDataFrame so I can open it without information loss?</p>