Problem with uploading library

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with uploading library

gaja
Hello.

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"

So, I would use some help. Thanx in advance.

Gaja
Reply | Threaded
Open this post in threaded view
|

Re: Problem with uploading library

Joshua Wiley-2
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")
############################

Hope that helps,

Josh


On Sat, Jan 1, 2011 at 1:25 PM, gaja <[hidden email]> wrote:

>
> Hello.
>
> 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"
>
> So, I would use some help. Thanx in advance.
>
> Gaja
> --
> View this message in context: http://r.789695.n4.nabble.com/Problem-with-uploading-library-tp3170455p3170455.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with uploading library

Jim Lemon
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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with uploading library

Jim Lemon
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.

Jim

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with uploading library

gaja
In reply to this post by Jim Lemon
wow guys, thanx for so quick reply. I'm in the office now, as soon as I get home, I'll try to do it!

Many thanx 
Reply | Threaded
Open this post in threaded view
|

Re: Problem with uploading library

gaja
Woho. I did it... Thanx guys ;)