[R] Problem with uploading library

Jim Lemon jim at bitwrit.com.au
Sun Jan 2 05:32:05 CET 2011


On 01/02/2011 12:54 PM, Joshua Wiley wrote:
> Dear Gaja,
>
> If "sp" and "maptools" are not already installed, you'll need to do
> that.  It is often recommended that you update your existing packages
> before installing new ones.  Once that is done (or if you have
> already), then you just need to load the packages, and then R will be
> able to find the readShapeSpatial() function (it is in the 'maptools'
> package).  Something like this should get you going:
>
> ########################
> update.packages()
> install.packages(c("sp", "maptools"))
> require(sp)
> require(maptools)
> ?readShapeSpatial #documentation
> towns<- readShapeSpatial("OB/OB.shp")
> ############################
>
Hi,
I have also been trying to read a shapefile:

SS10aAust.shp

with readOGR (rgdal)
and readShapeSpatial (maptools)

with absolutely no success, despite having long lost count of the help 
pages I have read seeking an example of how to do this:

readOGR("/home/jim/research/ombo/mapping/SSD10aAust.shp",
  layer="cities")
Error in ogrInfo(dsn = dsn, layer = layer, input_field_name_encoding = 
input_field_name_encoding) :
   Cannot open layer

I realize that one has to supply a layer here, but searching through the 
four files that were extracted from the ZIP file, there is no mention of 
layers. Obviously guessing on the basis of other examples doesn't work 
either.

ozmap<-readShapeSpatial(
  "/home/jim/research/ombo/mapping/SSD10aAust.shp")
Error in getinfo.shape(fn) : Error opening SHP file

All of the examples seem to deal with a different type of shape file 
that follows whatever rules are operating in these two functions. All of 
the examples and tutorials I have found on the Web are similarly 
inscrutable.

I guess I should start with asking how does one discover what layers are 
included in a shapefile? One step at a time...

Jim



More information about the R-help mailing list