I don't know then Yuster. Is your rgdal package up to date ?

________________________________________
From: Yuster Ronoh [yust...@gmail.com]
Sent: 28 November 2013 11:08
To: James Rooney
Cc: r-sig-geo@r-project.org
Subject: Re: [R-sig-Geo] Help - calling OpenBugs through R2OpenBugs problem

Yes I unzip the folder to no avail


On Thu, Nov 28, 2013 at 1:56 PM, James Rooney 
<roone...@tcd.ie<mailto:roone...@tcd.ie>> wrote:
Hi Yuster,

Did you unzip the file? Sorry I forgot to say that in instructions. You need to 
put the unzipped file into that directory.
James
________________________________________
From: Yuster Ronoh [yust...@gmail.com<mailto:yust...@gmail.com>]
Sent: 28 November 2013 10:21
To: James Rooney
Cc: r-sig-geo@r-project.org<mailto:r-sig-geo@r-project.org>
Subject: Re: [R-sig-Geo] Help - calling OpenBugs through R2OpenBugs problem

Hi James
I Downloaded the correct file from 
http://www.cso.ie/en/census/census2011boundaryfiles/  as 
Census2011_Electoral_Divisions_generalised20m zipfolder of 4mb data size ,I set 
working Directory as("C:/Users/Public/shapefile") in shapefile i pasted the 
downloaded folder as zip file I try to both was first 
SPolyDF<-readOGR("C:/Users/Public/shapefile","Census2011_Electoral_Divisions_generalised20m",TRUE)
 and for second time 
SPolyDF<-readOGR(".","Census2011_Electoral_Divisions_generalised20m",TRUE)returning
 the same error message.


On Thu, Nov 28, 2013 at 12:17 PM, James Rooney 
<roone...@tcd.ie<mailto:roone...@tcd.ie><mailto:roone...@tcd.ie<mailto:roone...@tcd.ie>>>
 wrote:
Hi Yuster,

Did you download the correct shapefile into "C:/Users/Public/shapefile" ?? 
There are alot of files there and I could not link directly to the file due to 
the "Disclaimer" page.

The other thing I find if I am having these kinds of errors from readOGR, is to 
paste the full pathway in quote into the readOGR instead of "."
In other words for your pathway if you are sure the right file is in the folder 
try this:

SPolyDF<-readOGR("C:/Users/Public/shapefile","Census2011_Electoral_Divisions_generalised20m",TRUE)

James

________________________________________
From: Yuster Ronoh 
[yust...@gmail.com<mailto:yust...@gmail.com><mailto:yust...@gmail.com<mailto:yust...@gmail.com>>]
Sent: 28 November 2013 09:11
To: James Rooney
Cc: 
r-sig-geo@r-project.org<mailto:r-sig-geo@r-project.org><mailto:r-sig-geo@r-project.org<mailto:r-sig-geo@r-project.org>>
Subject: Re: [R-sig-Geo] Help - calling OpenBugs through R2OpenBugs problem

Hi All
I try to follow the above example but i got stuck in reading Spatial Data Frame 
any Idea or Help?
Here are my R codes with error. I am using RStudio Version 3.0.2 ,Windows 7 
32Bit


Loading required package: sp
> library(rgdal)
rgdal: version: 0.8-12, (SVN revision 492)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.9.2, released 2012/10/08
Path to GDAL shared files: C:/Users/symon/R/win-library/3.0/rgdal/gdal
GDAL does not use iconv for recoding strings.
Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009, [PJ_VERSION: 470]
Path to PROJ.4 shared files: C:/Users/symon/R/win-library/3.0/rgdal/proj
> library(spdep)
Loading required package: Matrix
Loading required package: lattice
> library(R2OpenBUGS)
> setwd("C:/Users/Public/shapefile")
> #Read in Spatial Polygon Data Frame
> SPolyDF<-readOGR(".","Census2011_Electoral_Divisions_generalised20m",TRUE)
Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = 
use_iconv) :
  Cannot open file



On Thu, Nov 28, 2013 at 12:13 AM, James Rooney 
<roone...@tcd.ie<mailto:roone...@tcd.ie><mailto:roone...@tcd.ie<mailto:roone...@tcd.ie>><mailto:roone...@tcd.ie<mailto:roone...@tcd.ie><mailto:roone...@tcd.ie<mailto:roone...@tcd.ie>>>>
 wrote:
Dear Virgilio,

Many thanks for taking a look at it!

That  'debug = TRUE' is already set!!!! It doesn't make any difference!!

I'm running R in Windows 7 through Parallels on a Macbook Pro  (OSx Mavericks). 
I have shut down OsX and booted purely into windows and it doesn't make any 
difference.
I've experienced this problem under both R 2.15 and R 3.01. It also happens 
both in R Studio and in the standard R interface. I have Openbugs version 
3.2.2. Running latest version of the packages used.

My thinking is that something is crashing OpenBugs when it attempts to open - 
but I cant' figure out how or why. I wonder is there a file size limit for 
passing things into OpenBugs ?

Appreciate any help!
James

________________________________________
From: Virgilio Gómez-Rubio 
[virgilio.go...@uclm.es<mailto:virgilio.go...@uclm.es><mailto:virgilio.go...@uclm.es<mailto:virgilio.go...@uclm.es>><mailto:virgilio.go...@uclm.es<mailto:virgilio.go...@uclm.es><mailto:virgilio.go...@uclm.es<mailto:virgilio.go...@uclm.es>>>]
Sent: 27 November 2013 20:29
To: James Rooney
Cc: 
r-sig-geo@r-project.org<mailto:r-sig-geo@r-project.org><mailto:r-sig-geo@r-project.org<mailto:r-sig-geo@r-project.org>><mailto:r-sig-geo@r-project.org<mailto:r-sig-geo@r-project.org><mailto:r-sig-geo@r-project.org<mailto:r-sig-geo@r-project.org>>>
Subject: Re: [R-sig-Geo] Help - calling OpenBugs through R2OpenBugs problem

Dear James,

I'll be happy to look into this but I will need more information about
your system. Also, could you run the code using 'debug=TRUE' as seen in
the error message?

Best wishes,

Virgilio

On mié, 2013-11-27 at 20:13 +0000, James Rooney wrote:
> Hi everyone,
>
> Has anyone looked at this problem below ?
> Even if nobody has an answer I'd be keen to know if the problem replicated 
> for others.
>
> Many thanks,
>
> James
>
> ________________________________________
> From: 
> r-sig-geo-boun...@r-project.org<mailto:r-sig-geo-boun...@r-project.org><mailto:r-sig-geo-boun...@r-project.org<mailto:r-sig-geo-boun...@r-project.org>><mailto:r-sig-geo-boun...@r-project.org<mailto:r-sig-geo-boun...@r-project.org><mailto:r-sig-geo-boun...@r-project.org<mailto:r-sig-geo-boun...@r-project.org>>>
>  
> [r-sig-geo-boun...@r-project.org<mailto:r-sig-geo-boun...@r-project.org><mailto:r-sig-geo-boun...@r-project.org<mailto:r-sig-geo-boun...@r-project.org>><mailto:r-sig-geo-boun...@r-project.org<mailto:r-sig-geo-boun...@r-project.org><mailto:r-sig-geo-boun...@r-project.org<mailto:r-sig-geo-boun...@r-project.org>>>]
>  On Behalf Of James Rooney 
> [roone...@tcd.ie<mailto:roone...@tcd.ie><mailto:roone...@tcd.ie<mailto:roone...@tcd.ie>><mailto:roone...@tcd.ie<mailto:roone...@tcd.ie><mailto:roone...@tcd.ie<mailto:roone...@tcd.ie>>>]
> Sent: 23 November 2013 16:30
> To: 
> r-sig-geo@r-project.org<mailto:r-sig-geo@r-project.org><mailto:r-sig-geo@r-project.org<mailto:r-sig-geo@r-project.org>><mailto:r-sig-geo@r-project.org<mailto:r-sig-geo@r-project.org><mailto:r-sig-geo@r-project.org<mailto:r-sig-geo@r-project.org>>>
> Subject: [R-sig-Geo] Help - caling OpenBugs thourgh R2OpenBugs problem
>
> Hi all,
>
> I am working on a Bayesian spatial smoothing project - and have implemented 
> the BYM model, similar to the description in Chapter 11 of the ASDAR book. 
> However, I have been having a huge problem calling OpenBugs from within R and 
> I cannot figure out why. I would veyr much liek to do this as it would speed 
> up the whole process. I'm stared at this for a omnth or two now to no avail 
> so I'm hoping that somebody might spot a mistake. Basically when I call 
> OpenBugs from R using the bugs command through R2OpenBugs - it throws a 
> non-specific error and tells me to heck the bugs log file. The problem is 
> Bugs does not generate one. This is made all the weirder by the fact that if 
> I manually start up bugs and start it running using the data and inits files 
> gnerated by R2OpenBugs - it runs fine without complaint. This is how I have 
> been working so far. But I want to parallelize Bugs using Snow - so I need 
> R2OpenBugs to work properly. I'm hoping someone here can help!!!
>
> I've made a simulation to recreate the problem. My apologies it is a little 
> complex, but I wanted to use the shapefile I'm actually working with which is 
> freely downloadable for those willing to take a look.
> So here goes.
>
> 1. Go here for the shapefile:
> http://www.cso.ie/en/census/census2011boundaryfiles/
>
> 2. Click on the word "Disclaimer" to access the shapefiles (should you agree 
> with the disclaimer!!). After clicking through the Disclaimer stuff, the file 
> to download is: "Census2011_Electoral_Divisions_generalised20m.zip"
>
> 3. Set up a directory for this and save the shapefiles there.
>
> 4. You will need a bugs model. Cut and paste the below into a txt file and 
> save it to your directory under the name "spatial_CAR.txt"
>
> model
> {
>
>   for(i in 1:N)
>   {
>     observed[i]~dpois(mu[i])
>     log(theta[i])<-alpha + u[i] + v[i]
>     mu[i]<-expected[i]*theta[i]
>     u[i] ~dnorm(0,tau)
>   }
>
> v[1:N]~car.normal(adj[],weights[],num[],precv)
>
>   alpha ~dflat()
>   tau ~dgamma(0.001,0.001)
>   precv ~dgamma(0.1,0.1)
> }
>
> 5. Now open R and paste in the R code below. Remember to set your working 
> directory to the same directory you saved the shapefiles and bugs model into. 
> Also you might need to modify the path to OpenBugs on your machine.
>
> 6. Run the code. For me the final line throws the error:
> "Error in bugs.run(n.burnin, OpenBUGS.pgm, debug = debug, WINE = WINE,  :
>   Look at the log file in  C:......<SNIP>................./R2OpenBugs 
> Simulation  and
> try again with 'debug=TRUE' to figure out what went wrong within OpenBUGS."
>
> I cannot figure out why!!! The log file does not exist!! If you manually open 
> bugs and use the data and init files it works. Why ? No idea!!!!
> Any and all help much appreciated!!!
> Apologies for the length of this!!
>
> James
>
>
> R Code:
>
> library(rgdal)
> library(spdep)
> library(R2OpenBUGS)
>
> setwd("....your working directory here......")
>
> #Read in Spatial Polygon Data Frame
> SPolyDF<-readOGR(".","Census2011_Electoral_Divisions_generalised20m",TRUE)
>
> # Detect neighbours
> nb<-poly2nb(SPolyDF,queen=T,snap=0.1) # snap at 100m distance
>
> # Create nb weights
> nb.w<-nb2listw(nb,zero.policy=T,style="B")
>
> # Create BUGS CAR weights
> nbBugs<-listw2WB(nb.w)
>
> # Simulate some count data for observed and expected cases
> N<-nrow(SPolyDF)
> SPolyDF$obs<-sample.int<http://sample.int><http://sample.int><http://sample.int>(100,
>  N, TRUE)
> SPolyDF$exp<-sample.int<http://sample.int><http://sample.int><http://sample.int>(100,
>  N, TRUE)
>
> # Prep Data for OpenBugs
> d<-list(N = N, observed = SPolyDF$obs, expected = SPolyDF$exp, 
> adj=nbBugs$adj, weights=nbBugs$weights, num=nbBugs$num)
>
> # Specify dir where bugs lives
> BugsDir<-"C:/Program Files (x86)/OpenBUGS/OpenBUGS322"
>
> # Define initial values for bugs
> inits<-list(
>    list(u=rep(0,N),v=rep(0,N),alpha=0,tau=0.0001,precv=0.002)
>    ,list(u=rep(0,N),v=rep(0,N),alpha=0.1,tau=0.0002,precv=0.001))
>
> # Define working directory as current directory
> wdir=getwd()
>
> # Openbugs call
> MCMCres<-bugs(data=d,inits=inits,parameters.to.save 
> =c("theta","alpha","tau","precv"),
>               
> n.iter=1000,model.file="spatial_CAR.txt",n.chains=2,n.burnin=100,n.thin=1,
>               OpenBUGS.pgm=BugsDir,working.directory=wdir,codaPkg=F,debug=T)
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org<mailto:R-sig-Geo@r-project.org><mailto:R-sig-Geo@r-project.org<mailto:R-sig-Geo@r-project.org>><mailto:R-sig-Geo@r-project.org<mailto:R-sig-Geo@r-project.org><mailto:R-sig-Geo@r-project.org<mailto:R-sig-Geo@r-project.org>>>
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org<mailto:R-sig-Geo@r-project.org><mailto:R-sig-Geo@r-project.org<mailto:R-sig-Geo@r-project.org>><mailto:R-sig-Geo@r-project.org<mailto:R-sig-Geo@r-project.org><mailto:R-sig-Geo@r-project.org<mailto:R-sig-Geo@r-project.org>>>
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org<mailto:R-sig-Geo@r-project.org><mailto:R-sig-Geo@r-project.org<mailto:R-sig-Geo@r-project.org>><mailto:R-sig-Geo@r-project.org<mailto:R-sig-Geo@r-project.org><mailto:R-sig-Geo@r-project.org<mailto:R-sig-Geo@r-project.org>>>
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org<mailto:R-sig-Geo@r-project.org><mailto:R-sig-Geo@r-project.org<mailto:R-sig-Geo@r-project.org>>
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org<mailto:R-sig-Geo@r-project.org>
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to