[R-sig-Geo] Using "Mask" for SDMs (Maxent) with Dismo

Rafael Wüest rafael.wueest at wsl.ch
Tue Mar 6 15:11:37 CET 2012


Hi Johannes,

On 06.03.2012, at 14:45, Johannes Radinger wrote:

> Hi,
> 
> I have several environmental rasters (loaded as stack/brick) in R which I want to use as predictors for Species Distribution Models (preferably Maxent) with the dismo-package. Some of the predictors are habitat specific variables and are restricted to a river (like a line of raster cells, all land is NA) while others cover the total spatial extent (climatic variables). Thus I've also created a raster MASK which indicates the cells that have values (that are non-NAs) in ALL maps.
> 
> Now I've two questions:
> 1) How can I use such a MASK within e.g. maxent to restrict my background points and predictions etc. only to these cells?

you can use the mask command from the raster package. something like

newstack<-mask(yourstack,yourmask)

each layer in the newstack will only contain values in those cells that are indicated in your MASK raster. This way, maxent will only sample from those that are left...

> 2) How can I simply exclude presence points that are outside these masking raster cells? I want only those samples (presences of my species) that are sampled within my defined rivers.

There might be more elegant ways, but you can use the extract command:

extentraster<-setValues(yourstack[[1]],1)
index<-extract(extentraster,yourpoints)

Those points with NAs in the index are not within the extent of your raster stack.

HTH, Rafael

> 
> 
> Thank you,
> 
> Johannes
> -- 
> 
> Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a
> 
> _______________________________________________
> 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



More information about the R-sig-Geo mailing list