Problem of overlapping between the “raster” and “adehabitatHR” libraries

37 views
Skip to first unread message

bouderb...@gmail.com

unread,
Oct 10, 2020, 8:59:21 PM10/10/20
to Maxent

Hello all, 

I want to compare the results of two methods for the selection of the background data “buffer” and “minimum convex polygon (MCP)”. I use for the buffer the “raster” library and the “adehabitatHR” library for "MCP". The problem is I got this error message :

 library(raster) 

library(adehabitatHR)

 library(adehabitatMA)

 r <- raster(ncol=36,nrow=18) 

values(r) <- NA r[500] <- 1 

b <- buffer(r, 500000) 

c<- buffer(r, width=500000) 

I got two errors : 

1/ If I use "width" argument (buffer(r, width=500000)), I get : Error in buffer(r, width = 5e+05) : unused argument (width = 5e+05) 

2/ and if I use buffer(r, 500000) I get this error : Error in buffer(r, 5e+05) : x should inherit the class SpatialPixels 

How can I overcome this problem ? 

Thank you in advance 

Regards 

Bede-Fazekas Ákos

unread,
Oct 11, 2020, 3:13:52 AM10/11/20
to max...@googlegroups.com
Hello,

both 'raster' and 'adehabitatHR' have their own buffer() function. When you run library(adehabitatHR) you get some infos on the screen, including:
"The following object is masked from ‘package:raster’:
    buffer"
This means that when you call buffer(), R will call the buffer() function of adehabitatHR package, instead of that of the raster package.
There are three workarounds, I recommend no. 1:
1) Instead of buffer(), call raster::buffer()
2) Change the order of library(raster) and library(adehabitatHR)
3) Call library(adehabitatHR) after buffering.

HTH,
Ákos Bede-Fazekas
Hungarian Academy of Sciences
--
You received this message because you are subscribed to the Google Groups "Maxent" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maxent+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/maxent/ac3b50c6-d569-4f3c-a52b-62fdfe7b7ff7n%40googlegroups.com.

bouderb...@gmail.com

unread,
Oct 11, 2020, 10:40:52 PM10/11/20
to Maxent
Dear Ákos Bede-Fazekas, 

Thank you very much for your help it works with the option N°1. 

Please the width of the buffer represents the radius or the diameter of the buffer ? Because I can't find a detailed documentation. 
 


Bede-Fazekas Ákos

unread,
Oct 12, 2020, 1:34:29 AM10/12/20
to max...@googlegroups.com
Hello,
radius, I think.
Best,
Ákos
Reply all
Reply to author
Forward
0 new messages