title: How to convert .shp file into .csv in R?
body: <p>I want to to convert two .shp files into one database that would allow me to draw the maps together.</p>
  <p>Also, is there a way to convert .shp files into .csv files? I want to be able to personalize and add some data which is easier for me under a .csv format. What I have in mind if to add overlay yield data and precipitation data on the maps.</p>
  <p>Here are the shapefiles for <a href="https://www.dropbox.com/s/h0jnmj4byrmzn0r/MAR_adm1.shp" rel="nofollow noreferrer">Morocco</a>, and <a href="https://www.dropbox.com/s/7qqo0ykid3bstpb/ESH_adm1.shp" rel="nofollow noreferrer">Western Sahara</a>.</p>
  <p>Code to plot the two files:</p>
  <pre><code># This is code for mapping of CGE_Morocco results
  
  # Loading administrative coordinates for Morocco maps
  library(sp)
  library(maptools)
  library(mapdata)
  
  # Loading shape files
  Mor &lt;- readShapeSpatial(&quot;F:/Purdue University/RA_Position/PhD_ResearchandDissert/PhD_Draft/Country-CGE/MAR_adm1.shp&quot;)
  Sah &lt;- readShapeSpatial(&quot;F:/Purdue University/RA_Position/PhD_ResearchandDissert/PhD_Draft/Country-CGE/ESH_adm1.shp&quot;)
  
  # Ploting the maps (raw)
  png(&quot;Morocco.png&quot;)
  Morocco &lt;- readShapePoly(&quot;F:/Purdue University/RA_Position/PhD_ResearchandDissert/PhD_Draft/Country-CGE/MAR_adm1.shp&quot;)
  plot(Morocco)
  dev.off()
  
  png(&quot;WesternSahara.png&quot;)
  WesternSahara &lt;- readShapePoly(&quot;F:/Purdue University/RA_Position/PhD_ResearchandDissert/PhD_Draft/Country-CGE/ESH_adm1.shp&quot;)
  plot(WesternSahara)
  dev.off()
  </code></pre>
  <p><img src="https://i.stack.imgur.com/pK1Vh.png" alt="Morocco" />
  <img src="https://i.stack.imgur.com/31JTS.png" alt="WesternSahara" /></p>
  <p>After looking into suggestions from @AriBFriedman and @PaulHiemstra and subsequently figuring out how to merge .shp files, I have managed to produce the following map using the following code and data (For .shp data, cf. links above)</p>
  <p>code:</p>
  <pre><code># Merging Mor and Sah .shp files into one .shp file
  
  MoroccoData &lt;- rbind(Mor@data,Sah@data) # First, 'stack' the attribute list rows using rbind() 
  MoroccoPolys &lt;- c(Mor@polygons,Sah@polygons) # Next, combine the two polygon lists into a single list using c()
  
  summary(MoroccoData)
  summary(MoroccoPolys)
  
  offset &lt;- length(MoroccoPolys) # Next, generate a new polygon ID for the new SpatialPolygonDataFrame object
  
  browser()
  for (i in 1: offset)
  {
  sNew =  as.character(i)
  MoroccoPolys[[i]]@ID = sNew
  }
  
  ID &lt;- c(as.character(1:length(MoroccoPolys))) # Create an identical ID field and append it to the merged Data component
  MoroccoDataWithID &lt;- cbind(ID,MoroccoData)
  
  MoroccoPolysSP &lt;- SpatialPolygons(MoroccoPolys,proj4string=CRS(proj4string(Sah))) #  Promote the merged list to a SpatialPolygons data object
  
  Morocco &lt;- SpatialPolygonsDataFrame(MoroccoPolysSP,data = MoroccoDataWithID,match.ID = FALSE) #  Combine the merged Data and Polygon components into a new SpatialPolygonsDataFrame.
  
  Morocco@data$id &lt;- rownames(Morocco@data)
  Morocco.fort &lt;- fortify(Morocco, region='id') 
  Morocco.fort &lt;- Morocco.fort[order(Morocco.fort$order), ] 
  
  MoroccoMap &lt;- ggplot(data=Morocco.fort, aes(long, lat, group=group)) + 
  geom_polygon(colour='black',fill='white') + 
  theme_bw()
  </code></pre>
  <p>Results:</p>
  <p><img src="https://i.stack.imgur.com/GBbtz.png" alt="MoroccoMAp" /></p>
  <p>New Question:</p>
  <p>1- How to eliminate the boundaries data that cuts though the map in half?</p>
  <p>2- How to combine different regions within a .shp file?</p>
  <p>Thanks you all.</p>
  <p>P.S: the community in stackoverflow.com is wonderful and very helpful, and especially toward beginners like :) Just thought of emphasizing it.</p>