Closed carmerlun closed 9 months ago
Hello there,
Thank you for your nice issue with plenty of details :star2: :pray:
You can definitely give your data as data.frame
to avoid the extraction of environmental values over the same environmental raster layers. To do so, you need to give 1 vector
and 2 data.frame
objects to resp.var
, resp.xy
and expl.var
parameters respectively within the BIOMOD_FormatingData function.
Let's say for the example that you have 110 presences, 1000 pseudo-absence points that you selected yourself, and 3 environmental variables :
resp.var
will be a vector
containing 110 1
and 1000 NA
values (c(rep(1, 110), rep(NA, 1000))
)resp.xy
will be a data.frame
with 2 columns and 1110 rows, the first 110 rows corresponding to the coordinates of your presences, and the rest to the coordinates of your sampled pseudo-absencesexpl.var
will be a data.frame
with 3 columns and 1110 rows, same as above, with rows matching the order of points given in resp.var
and resp.xy
This way, environmental values can come from different temporal layers between points. The important thing is to keep the same order of points between the 3 parameters.
Note that you can also combine resp.var
and resp.xy
in one by giving a SpatVector
object to resp.var
if you prefer.
Hope it helps, Maya
Thank you so much, Maya, for your quick and neat reply. I tried your directions and the function works perfect. Best regards!
Context and question When I fit species distribution models (SDM) using biomod2 in R I need to provide the locations (XY coordinates) of the species (both the presence and pseudo-absence or background points, usually from a matrix or dataframe) and the environmental variables (which is usually available as raster layers). This way the function BIOMOD_Modeling() extracts the environmental info at the specific locations of the presence/absence points, such as:
But, is there a way to provide the environmental info so that the function doesn't need to do that extraction job. I need this becasue I have several periods of time and I already did the job of extracting the environmental info at the specific place and time of each observation. I also generated the random background points assigning them to different areas and times and created the corresponding dataframe with the absence/absence points and environmental info.
Can I provide directly this dataframe to either BIOMOD_FormatingData() or BIOMOD_Modeling() or another function in the biomod2 package?
Environment Information I'm using biomod2 version 4.2-4 and R version 4.2.2 running under debian bookworm.