I think this is it: http://www.biostat.umn.edu/~brad/yuecui/index.html http://www.biostat.umn.edu/~brad/yuecui/convert.r
#/09/23/03 The only different btw this convert.r and convert.s is that #in convert.s, we us AsciiToInt("character")-AsciiToInt("0") to change #character into numeric, in convert.r, we use type.convert("character") #to do this. #/09/23/03 #This version of convert.s corrects the problems found in convert2&3.s #Tried every combination of options for scan, the following doesn't work. #checking by comparing the number of observations in fortest and in .cgm file #fortest<-scan("test.cgm",what=list(name=""),widths=c(90),multi.line=F,sep="\n") #source("convert.r") convert<-function(cgmfile) { #outfile <- "test.txt" outfile<-paste(cgmfile,".txt",sep="") #This one works #fortest<-scan("test.cgm",what=list(name=""),sep="\n") fortest<-scan(paste(cgmfile,".cgm",sep=""),what=list(name=""),sep="\n") fortest<-fortest$name fortest<-fortest[grep("VIS",fortest)] fortest<-as.matrix(fortest) totpolyn<-length(fortest[grep("POLYGON_SET",fortest)]) polyn<-0 count<-0; indicator<-0; #First tried rep(0,1000), but there is a polygon with 167 rows, so we get #167*3*2=1002 coordinates in one polygon. Error occurs with NA output coord<-rep(0,5000) write(paste("map:",totpolyn,"\n"),outfile) for (i in 1:totpolyn) { write(paste( i, paste("grid",i,sep="")),outfile,append=T) } for (i in 1:length(fortest)){ for(j in (1:nchar(fortest[i]))){ letter<-substring(fortest[i],j,j) #At first try to use AsciiToInt,stupid #if (AsciiToInt(letter)<=AsciiToInt("9")& # AsciiToInt(letter)>=AsciiToInt("0")) if(letter<="9"&letter>="0"){ if (indicator==0) {count<-count+1; indicator<- 1 } coord[count]<-coord[count]*10+ type.convert(letter) } #add the following else if statement because if and only when #a POLYGON_SET is encounted, polyn is increased by 1 else if (letter=="P"){ polyn<-polyn+1;indicator<-0} #a CLOSEVIS is encounted, output the coordinates set, this is #done independently with increase of polyn since a POLYGON_SET may #consist of several small polygons else if(letter=="C"){ coordmat<-cbind(rep(paste("grid",polyn,sep=""),count/2), coord[2*(1:(count/2))-1], coord[2*(1:(count/2))]) if (polyn == 1) { write("",outfile,append=T)} else { write(c(NA,NA,NA),outfile,append=T)} write(t(coordmat),outfile,append=T,ncol=3) #polyn<-polyn+1 #the above statement is not right because 2 CLOSEVIS may lie in one #same polygon, but we output a polygon coordinates set whenever a #CLOSEVIS is encountered, although it may have the same label, #denoted by "grid&polyn" with previous or next coordinate sets. count<-0 indicator<-0 coord<-rep(0,5000) #if(grep("\r",substring(fortest[i],j+1,nchar(fortest[i])))) #break } else indicator<-0 } } write("END",outfile,append=T) } On Thu, Feb 5, 2009 at 6:16 PM, Tord Snäll <tord.sn...@ekol.slu.se> wrote: > Dear all, > I would like to read in ArcView (or ArcGIS) shape files from which I will > pick information if fitting a geostatistical model using WinBUGS. In the > GeoBUGS Used Manual it says > "GeoBUGS does not have an option for loading ArcView shape files directly. > However, Ms Yue Cui at the University of Minnesota has written programs in > Splus and R for converting shape files into the GeoBUGS Splus format so that > they can be loaded in GeoBUGS (http://www.biostat.umn.edu/~yuecui/). " > > Unfortunately this site is unavailable, and the Biostatstics homepage at > University of Minnesota does not say anything about neither BUGS nor Ms Yue > Cui. > > Does anyone know whether this code has been included in any R library, or > does anyone know how to get in touch with Ms Yue Cui? I find some old > questions about this is the archive, but at that time no one seemed to know > about this. > > Thanks, > Tord > > -- > > Tord Snäll > Department of Ecology > Swedish University of Agricultural Sciences (SLU) > P.O. 7044, SE-750 07 Uppsala, Sweden > Office/Mobile/Fax > +46-18-672612/+46-76-7662612/+46-18-673537 > E-mail: tord.sn...@ekol.slu.se www.ekol.slu.se/staff_tordsnall > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo