Using package dismo in R

1,187 views
Skip to first unread message

arnald

unread,
Apr 20, 2010, 5:37:31 AM4/20/10
to Maxent
Hello to everyone,

Is anybody starting to use package dismo in R to run maxent models. I
have not found a way to pass arguments from within R to maxent. Can
anybody share a code example on how to do this. I tried the example in
the R maxent documentation but have not found a way to get the same
result from within R as from directly using maxent.jar, although dismo
package actually uses maxent.jar.

Any help in the form of a code example would be appreciated.

Also I have found that the function randomPoints returns all points
in the upper north part of the envelope of the raster provided when
more than 6864 points are asked for. Anyone observed this behaviour.
Below 6864 results are correct.

Thank you very much,

Arnald Marcer
CREAF - Centre for Ecological Research and Forestry Applications

--
You received this message because you are subscribed to the Google Groups "Maxent" group.
To post to this group, send email to max...@googlegroups.com.
To unsubscribe from this group, send email to maxent+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/maxent?hl=en.

Peter Wilson

unread,
Apr 20, 2010, 5:50:03 PM4/20/10
to max...@googlegroups.com
Hello Arnald,

You do not need package dismo to run MaxEnt from within R. The inbuilt R function "system" will run it for you. See the R help file on this function.

Here, for example, is how to start the MaxEnt GUI from within R on a Windows system:

system(paste('"java"','-mx512m -jar J:/Stuff/maxent.jar'), wait = FALSE)

where "J:/Stuff/" should be changed to provide the path to the folder in which you installed the maxent.jar file. The way long pathnames to files with embedded spaces is handled varies between Windows and Unix/Linux/Mac OSX versions of the R environment ( e.g. "D:/My MaxEnt stuff/Species A").

To run MaxEnt in batch mode, you simply add parts to the second argument of the paste function. Here is how the batch example in the MaxEnt tutorial looks for a Windows version of R:

system(paste('"java"','-mx512m -jar J:/Stuff/maxent.jar -e layers -t eco -s samples/bradypus.csv -o outputs -r -a'), wait = TRUE)

The full range of batch options can be added to the second argument of the paste function - see the MaxEnt help file.

Note that, because of its Unix origins, R defaults to using forward slashes in pathnames (it can use a DOS/Windows backslash but it must be doubled or "escaped" in Unix jargon i.e. samples/bradypus.csv would be sample\\bradypus.csv, a trap for beginners).

You can run a sequence of MaxEnt jobs, say for a list of species, by putting the system() call inside a loop with sample file names, etc taken from lists.

Hope this is helps.

Cheers,

Peter Wilson

==========================================
Dr Peter D. Wilson
Postdoctoral Research Fellow
Department of Biological Sciences
Macquarie University, New South Wales, Australia 2109
Email: pwi...@bio.mq.edu.au
>>> arnald <arnald...@gmail.com> 04/21/10 5:11 AM >>>

arnald

unread,
Apr 21, 2010, 1:30:26 AM4/21/10
to Maxent
Thank you Peter for your suggestion. I knew of this possibility.
However, there are advantages in using package dismo since you can
directly 'capture' the maxent result model in R and be able to use it
to predict, evaluate and combine with other R functionality. However,
when I use it from dismo i have not found the correct way to pass the
parameters in the 'args' option of the maxent function in R.

Arnald

On Apr 20, 11:50 pm, "Peter Wilson" <pwil...@bio.mq.edu.au> wrote:
> Hello Arnald,
>
> You do not need package dismo to run MaxEnt from within R. The inbuilt R function "system" will run it for you. See the R help file on this function.
>
> Here, for example, is how to start the MaxEnt GUI from within R on a Windows system:
>
> system(paste('"java"','-mx512m -jar J:/Stuff/maxent.jar'), wait = FALSE)
>
> where "J:/Stuff/" should be changed to provide the path to the folder in which you installed the maxent.jar file. The way long pathnames to files with embedded spaces is handled varies between Windows and Unix/Linux/Mac OSX versions of the R environment ( e.g. "D:/My MaxEnt stuff/Species A").
>
> To run MaxEnt in batch mode, you simply add parts to the second argument of the paste function. Here is how the batch example in the MaxEnt tutorial looks for a Windows version of R:
>
> system(paste('"java"','-mx512m -jar J:/Stuff/maxent.jar -e layers -t eco -s samples/bradypus.csv -o outputs -r -a'), wait = TRUE)
>
> The full range of batch options can be added to the second argument of the paste function - see the MaxEnt help file.
>
> Note that, because of its Unix origins, R defaults to using forward slashes in pathnames (it can use a DOS/Windows backslash but it must be doubled or "escaped" in Unix jargon i.e. samples/bradypus.csv would be sample\\bradypus.csv, a trap for beginners).
>
> You can run a sequence of MaxEnt jobs, say for a list of species, by putting the system() call inside a loop with sample file names, etc taken from lists.
>
> Hope this is helps.
>
> Cheers,
>
> Peter Wilson
>
> ==========================================
> Dr Peter D. Wilson
> Postdoctoral Research Fellow
> Department of Biological Sciences
> Macquarie University, New South Wales, Australia 2109
> Email: pwil...@bio.mq.edu.au>>> arnald <arnald.mar...@gmail.com> 04/21/10 5:11 AM >>>
>
> Hello to everyone,
>
> Is anybody starting to use package dismo in R to run maxent models. I
> have not found a way to pass arguments from within R to maxent. Can
> anybody share a code example on how to do this. I tried the example in
> the R maxent documentation but have not found a way to get the same
> result from within R as from directly using maxent.jar, although dismo
> package actually uses maxent.jar.
>
> Any help in the form of a code example would be appreciated.
>
> Also I have found that the function randomPoints  returns all points
> in the upper north part of the envelope of the raster provided when
> more than 6864 points are asked for. Anyone observed this behaviour.
> Below 6864 results are correct.
>
> Thank you very much,
>
> Arnald Marcer
> CREAF - Centre for Ecological Research and Forestry Applications
>
> --
> You received this message because you are subscribed to the Google Groups "Maxent" group.
> To post to this group, send email to max...@googlegroups.com.
> To unsubscribe from this group, send email to maxent+un...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/maxent?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "Maxent" group.
> To post to this group, send email to max...@googlegroups.com.
> To unsubscribe from this group, send email to maxent+un...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/maxent?hl=en.
Reply all
Reply to author
Forward
0 new messages