title: Export a polygon from an R plot as a shapefile
body: <p>I have been trying to export the content of a plot (lines/polygons) as a layer/shapefile that I can open in ArcMap. These are some of the libraries that I have been using,</p>
  
  <blockquote>
  <pre><code>library(shapefiles)
  library(PBSmapping)
  library(adehabitatHR)
  library(maptools)
  library(maps)
  library(rgdal)
  library(igraph)
  </code></pre>
  </blockquote>
  
  <p>My lat/long data looks like this:</p>
  
  <blockquote>
  <pre><code>tagdata&lt;-read.table(text="meanlat  meanlong
  -18.63327 147.0248
  -18.6368  147.0238
  -18.62068 147.294
  -18.62953 147.2942
  -18.62953 147.2942
  -18.62091 147.2938
  -18.62953 147.2942
  -18.62466 147.2926
  -18.73393 147.2816
  -18.73393 147.2816
  -18.75383 147.2541
  -18.75383 147.2541
  -18.75383 147.2541
  -18.75383 147.2541
  -18.6368  147.0238
  -18.63063 147.0256
  -18.63063 147.0256
  -18.68133 147.1164
  -18.6368  147.0238
  -18.63063 147.0256
  -18.63063 147.0256
  -18.75383 147.2541
  -18.61273 147.0682
  -18.69655 147.09
  -18.6368  147.0238
  -18.63063 147.0256
  -18.63063 147.0256
  -18.63217 147.0251
  -18.75383 147.2541
  -18.75383 147.2541
  -18.75383 147.2541
  -18.63063 147.0256
  -18.68133 147.1164
  -18.68133 147.1164
  -18.63217 147.0251
  -18.69922 147.0909
  -18.73393 147.2816
  -18.63632 147.0792
  -18.69522 147.0896
  -18.6368  147.0238
  -18.75383 147.2541
  -18.75383 147.2541
  -18.75383 147.2541",header=TRUE)
  </code></pre>
  </blockquote>
  
  <p>I plotted the locations and calculated the Minimum Convex Polygon (MCP) using the AdehabitatHR package.</p>
  
  <blockquote>
  <pre><code>plot(tagdata$meanlong,tagdata$meanlat, col="red",pch=1)                  
  
  loc&lt;-tagdata[ ,c("meanlong","meanlat")]
  coord&lt;-SpatialPoints(loc)
  poly&lt;-mcp(coord,percent=100)
  plot(poly,add=TRUE)
  </code></pre>
  </blockquote>
  
  <p>I know how to export/write points as shapefile that I can open in ArcMap or similar softwares,</p>
  
  <p>For example:</p>
  
  <blockquote>
  <pre><code>loc&lt;-SpatialPoints(loc) # #convert loc to spatial points
  rem&lt;-tagdata[c(-1:-2)] 
  SpatialPointsDataFrame(coords=loc,data=rem) 
  obj&lt;-SpatialPointsDataFrame(coords=loc,data=rem)
  writePointsShape(obj,"myshape.shp")
  </code></pre>
  </blockquote>
  
  <p>However, I haven't found a good way to do it with a polygon o polyline object. I would loke to be able to export/write the poly object with the MCP as a shapefile. Any suggestions?</p>