I'm new on that forum, so I would use some help... I'm programing with R program, have some exercise to do.
So here it goes.
1. I have to upload two libraryes "sp" and "maptools"
2. This command is troubling me : towns <- readShapeSpatial("OB/OB.shp")
3. When I'm pressing f5, there is an error called: Error: could not find function "readShapeSpatial"
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:
> 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:
> install.packages(c("sp", "maptools"))
> ?readShapeSpatial #documentation
> towns<- readShapeSpatial("OB/OB.shp")
I have also been trying to read a shapefile:
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:
Error in ogrInfo(dsn = dsn, layer = layer, 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
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
I guess I should start with asking how does one discover what layers are
included in a shapefile? One step at a time...
On 01/02/2011 04:18 PM, Joshua Wiley wrote:
> This makes me wonder if you could somehow have it return any or all layers?
One of the first things I did was look for a function that would return
all the information I needed to know. I thought that "ogrInfo" might do
the trick, but it doesn't.
> When I was browsing, I ran across this whitepaper on shapefiles:
> http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf >
Thanks for that, I now know quite a bit more about shapefiles, but no
mention of layers.
> perhaps it will be useful/mean something to you.
I'm a bit further down the track, I'll keep looking. Thanks.