Maria--

I believe that your problem is with the line:
s1<-readShapePoly("shapes[i]", verbose=T)

It may be as simple as removing the quote marks:
s1<-readShapePoly(shapes[i], verbose=T)
as shapes is a vector of character.  However, I use rgdal::readOGR() to
read shapefiles, so your mileage may vary, specifically on whether you need
to drop the file extension .shp via something like:
shapes <- sub('\\.shp$','',shapes)

I hope that this helps.  If you have problems with the actual computations,
r-sig-geo might be a more useful list, but please do not cross post to both
lists.

Tom


On Wed, Sep 18, 2013 at 3:08 PM, Maria Fernanda Bonetti <
fernanda_bonetti@hotmail.com> wrote:

> Hi allI need to extract climatic variables of many shapefiles. I did a
> function to do this, but appears a error "Error in getinfo.shape(filen) :
> Error opening SHP file".
> These are some shapes that I will need use (
> https://dl.dropboxusercontent.com/u/10809384/bios/shapes/teste.zip - just
> to use how example). The climatic variables I downloaded from Bioclim
> (.bil).
> This is the function:
> library(raster)library(rgdal)library(maptools)library (rgeos)library
> (gpclib)
> #listing the shapes in directoryshapes<-grep("\\.shp$",
> list.files(recursive=T), value=T)len<-length(shapes)
> # listing all .bil rastersbios<-list.files(pattern='bil', full.names=T)
> biosT<-stack(bios[1:5]) # Just testing with the first 5 rasters from Bioclim
>
> Temperatura<-list()nomes<-list ()for(i in 1:length(shapes)){
>  s1<-readShapePoly("shapes[i]", verbose=T)
>  nomes[[i]]<-as.character(s1$SCI_NAME)  dados<-extract(biosT, s1, df=T)
>  media<-sapply(dados, mean, na.rm=T)  minimo<-sapply(dados, min, na.rm=T)
>  maximo<-sapply(dados, max, na.rm=T)  mediana<-sapply(dados, median,
> na.rm=T)  desvio<-sapply(dados, sd, na.rm=T)  soma<-sapply(dados, sum,
> na.rm=T)  coef.var<-sapply(dados, cv, na.rm=T)  results<-cbind(media,
> desvio, minimo, maximo, mediana, coef.var, soma)
>  Temperatura[[i]]<-results}(here appears the error) Error in
> getinfo.shape(filen) : Error opening SHP file
> names(Temperatura)<-nomes
> library(plyr)df<-ldply(Temperatura,
> data.frame)df$bio<-c("id","bio1","bio2","bio3","bio4","bio5","bio6","bio7","bio8","bio9","bio10","bio11")
> table (table(paste(teste$ID, teste$SCI_NAME, sep="")))
>
>
> Someone knows what is happening and how can I fix it?
>
>
> Maria Fernanda Bonetti
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>



-- 
-------------------------------------------
Tom Philippi, Ph.D.
Quantitative Ecologist & Data Therapist
Inventory and Monitoring Program
National Park Service
Tom_Philippi@nps.gov
http://science.nature.nps.gov/im/monitor

	[[alternative HTML version deleted]]

