0

How to convert from shape into polygon in R? There was shape2poly(shapefiles) but this function have been removed, are shapefiles, maptools, spdep still packages for handling maps in R?

rcs
  • 67,191
  • 22
  • 172
  • 153
Qbik
  • 5,885
  • 14
  • 62
  • 93
  • 1
    Maybe this : `library(maptools);my.shapefile <- read.shape("shapefile.shp")` can help you? – agstudy Jun 24 '13 at 17:37
  • @agstudy `Error: could not find function "read.shape"`, so your function is outdated as my shape2poly(shapefiles) – Qbik Jun 25 '13 at 08:53
  • it is not mine :) looks like convert a shape to a polygon is has-been habit :) – agstudy Jun 25 '13 at 09:01
  • If you give us a description of your ultimate goal - do you want to plot a map, for example? - the chances of you getting a useful answer will be much higher. If you want to plot a map, the answer below shows you how to read a shapefile and [other answers](http://stackoverflow.com/questions/13655230/how-do-you-combine-a-map-with-complex-display-of-points-in-ggplot2/13655715#13655715) on this site show you how to plot a map. – SlowLearner Jun 28 '13 at 06:00

1 Answers1

2

I tend to use the OGR stuff, as it lets me work with data from a range of sources (geodatabases, kml, etc).

library(rgdal)
mylayer <- readOGR(dsn="/path/to/folder/containing/shapefile",
                   layer="shapefilename-minus-dot-shp")
Peter
  • 4,219
  • 4
  • 28
  • 40