[R-sig-Geo] connection error when calling maxent()

Rafael Wüest rafael.wueest at wsl.ch
Sat Jan 21 18:08:59 CET 2012


Dear Robert,

I have a question related to the workaround I so far used (specifying the path argument in  dismo::maxent).

I fit a model:

md<-maxent(...,path='my/wanted/path')

Then save it:

save(md,file='another/path/maxent_md')

I wanted to save it because I need it for further analyses.

Now, in a totally independent R session, I load the model file:

load('another/path/maxent_md')

When I now try to predict:

predict(md,myrasterstack)

, I am getting the following error:

Error in  file(file, ifelse(append, "a", "w")) : 
  can't open connection
In addition : Warning:
In file(file, ifelse(append, "a", "w")) :
  can't open file '/var/folders/ft/fthJYD+6GkCvmcCArZBaQU++waU/-Tmp-/R_raster_tmp/maxent/lambdas.csv': No such file or directory

It seems like, even though I specified the path argument when generating md, it is not passed on to md but only the maxent output gets written to the specified path.

Is there a possibility to specify the path where the predict function is looking for the maxent-specific files (couldn't find anything in the web, this list)? Or, in my user-view even better, pass the path on to the generated md object. Anyway, this would allow me to further use such a model object of the class MaxEnt.

Rafael



On 15.01.2012, at 03:12, Robert J. Hijmans wrote:

> Rafael,
> 
> The issue here would be the version of raster, not R (as long as it is >= 2.11.0); but I agree that you have found a good solution.  And the error is a rather different one that you originally reported:
> 
> > Error: No features available: select more feature types or deselect auto features
> 
> Unless you did not copy this line when you first reported the problem...
>  
> That error comes from MaxEnt, and clearly states that there is something wrong with the feature selection. I do not know why. Perhaps because of one of the MaxEnt options you use, perhaps in combination with only a few point records? That is a subject more suitable for the MaxEnt discussion forum. 
> 
> Because MaxEnt fails to run, further errors occur, but the trouble starts with the line above. So it seems that your method works, except for MaxEnt run 46
> 
> Robert
> 
> 
> On Sat, Jan 14, 2012 at 3:51 AM, Rafael Wüest <rafael.wueest at wsl.ch> wrote:
> Dear Robert,
> 
> Unfortunately, the problem is not completely solved for me yet. I am trying to run maxent() on a cluster, because I'm modeling >200 species, using 8 different parameterizations and 4 modeling algorithms (maxent is one of them), which results in >6000 models. The cluster is running R 2.12.2 and I can't update it on my own.
> 
> As a workaround, I tried to specify the path option in the maxent() function because I suspected some process might interfere with the temporary Raster directory. This seemed to run for quite some time, but after maxent being called for the 46th on one of the cluster's CPU, it crashed with the same error
> 
> > Error: No features available: select more feature types or deselect auto features
> > Error in file(con, "r") : cannot open the connection
> > Calls: run4models ... maxent -> maxent -> .local -> unlist -> readLines -> file
> > In addition: Warning message:
> > In file(con, "r") :
> >   cannot open file '/.../me_output/xval/species.lambdas': No such file or directory
> > Execution halted
> 
> Do you have any idea how I could still make maxent() functional using R 2.12.2?
> 
> Rafael
> 
> 
> On 12.01.2012, at 01:33, Robert J. Hijmans wrote:
> 
> > Rafael,
> >
> > Please send more info about what you are doing. It appears that the MaxEnt output file gets overwritten by another process. Can you also send your sessionInfo() (after first updating R to a more recent version)?
> >
> > Robert
> >
> >
> > On Wed, Jan 4, 2012 at 8:52 AM, rafael.wueest <rafael.wueest at wsl.ch> wrote:
> > Hi Folks
> >
> > when I am trying to call the maxent() function within a function I created,
> > I am getting the following error:
> >
> > Error in file(con, "r") : cannot open the connection
> > In addition: Warning message:
> > In file(con, "r") :
> >  cannot open file
> > '/var/folders/ft/fthJYD+6GkCvmcCArZBaQU++waU/-Tmp-/R_raster_tmp/maxent/10943312360/species.lambdas':
> > No such file or directory
> >
> > I am here also pasting some output of
> > >traceback()
> > 7: file(con, "r")
> > 6: readLines(paste(dirout, "/species.lambdas", sep = ""))
> > 5: unlist(readLines(paste(dirout, "/species.lambdas", sep = "")))
> > 4: .local(x, p, ...)
> > 3: maxent(background, occ, args = me.args) at run4models_restios.r#558
> > ...
> >
> > I am using JGR on a Mac and downloaded the newest dismo (CRAN sources) and
> > maxent version (see below).
> >
> > Can anyone help me? I am happy to provide more detailed information...
> >
> > Rafa
> >
> > >maxent()
> > This is MaxEnt version 3.3.3k
> >
> > >sessionInfo()
> > R version 2.12.2 (2011-02-25)
> > Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
> >
> > locale:
> > [1] C
> >
> > attached base packages:
> > [1] splines   stats     graphics  grDevices utils     datasets  methods
> > [8] base
> >
> > other attached packages:
> >  [1] gbm_1.6-3.1           survival_2.36-5       gam_1.04.1
> >  [4] PresenceAbsence_1.1.5 maptools_0.8-10       lattice_0.19-33
> >  [7] foreign_0.8-42        rgdal_0.6-33          dismo_0.7-14
> > [10] raster_1.9-13         sp_0.9-84             JGR_1.7-7
> > [13] iplots_1.1-4          JavaGD_0.5-4          rJava_0.9-1
> >
> > loaded via a namespace (and not attached):
> > [1] grid_2.12.2  tools_2.12.2
> > Warning message:
> > 'DESCRIPTION' file has 'Encoding' field and re-encoding is not possible
> >
> >
> > --
> > View this message in context: http://r-sig-geo.2731867.n2.nabble.com/connection-error-when-calling-maxent-tp7151125p7151125.html
> > Sent from the R-sig-geo mailing list archive at Nabble.com.
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo at r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
> 
> 
> 
> --
> Rafael Wüest
> Swiss Federal Research Institute WSL
> Zürcherstrasse 111
> 8903 Birmensdorf
> Switzerland
> 
> +41 44 7392126
> rafael.wueest at wsl.ch
> http://www.wsl.ch/info/mitarbeitende/wueest
> 
> 
> 
> 



--
Rafael Wüest
Swiss Federal Research Institute WSL
Zürcherstrasse 111
8903 Birmensdorf
Switzerland

+41 44 7392126
rafael.wueest at wsl.ch
http://www.wsl.ch/info/mitarbeitende/wueest



More information about the R-sig-Geo mailing list