[Biomod-commits] Accessing XY coordinated for absence data

Damien Georges damien.georges2 at gmail.com
Fri Jul 26 13:03:54 CEST 2013


Dear Jenny,

To get PA xy coordinates, you have to look within BIOMOD.formated.data 
object.. Here an example with biomod2 data.. You should be able to adapt 
it to your own case of study..


##########################################################
library(biomod2)

# species occurrences
DataSpecies <- read.csv(system.file("external/species/mammals_table.csv",
                                     package="biomod2"), row.names = 1)
head(DataSpecies)

# the name of studied species
myRespName <- 'GuloGulo'

# the presence only data for our species
myResp <- as.numeric(DataSpecies[,myRespName])
myRespXY <- DataSpecies[myResp==1,c("X_WGS84","Y_WGS84")]
myResp <- myResp[myResp==1]



# Environmental variables extracted from BIOCLIM (bio_3, bio_4, bio_7, 
bio_11 & bio_12)
myExpl = stack( system.file( "external/bioclim/current/bio3.grd",
                              package="biomod2"),
                 system.file( "external/bioclim/current/bio4.grd",
                              package="biomod2"),
                 system.file( "external/bioclim/current/bio7.grd",
                              package="biomod2"),
                 system.file( "external/bioclim/current/bio11.grd",
                              package="biomod2"),
                 system.file( "external/bioclim/current/bio12.grd",
                              package="biomod2"))

# 1. Formatting Data
myBiomodData <- BIOMOD_FormatingData(resp.var = myResp,
                                      expl.var = myExpl,
                                      resp.xy = myRespXY,
                                      resp.name = myRespName,
                                      PA.nb.rep=3,
                                      PA.nb.absences=100)


PA_coords_table <- 
cbind(myBiomodData at coord,myBiomodData at data.species,myBiomodData at PA)
head(PA_coords_table)

## extract for xy for PA1 (pres, abs and PA)
xyPA1_allpts <- PA_coords_table[ PA_coords_table$PA1 ,1:2]

## extract for xy for PA1 only PA
xyPA1_onlyPApts <- PA_coords_table[ (PA_coords_table$PA1 & 
is.na(PA_coords_table[,3])),1:2]
##########################################################

Hope that helps,
Damien.


On 26/07/2013 12:34, Jenny Williams wrote:
> I am trying to get an XY table of the pseudo-absence data generated in BIOMOD_FormatingData.
>
> I understand that the PA's are stored in the hidden folder, but not sure how to source them back to R and therefore extract to *.csv or *.txt
>
> I have tried :
> showClass("BIOMOD.formated.data")
> BIOMOD.formated.data$PA
>
> But only get an error:
> Error in BIOMOD_FormatingData$PA.table :
>    object of type 'closure' is not subsettable
>
> ******************
> Jenny Williams
> Spatial Information Scientist, GIS Unit
> Herbarium, Library, Art & Archives Directorate
> Royal Botanic Gardens, Kew
> Richmond, TW9 3AB, UK
>
> Tel: +44 (0)208 332 5277
> email: jenny.williams at kew.org<mailto:jenny.williams at kew.org>
> ******************
>
> Film: The Forgotten Home of Coffee - Beyond the Gardens<http://www.youtube.com/watch?v=-uDtytKMKpA&sns=tw>
> Stories: Coffee Expedition - Ethiopia<http://storify.com/KewGIS/coffee-expedition-ethiopia>
>               Kew in Harapan Rainforest Sumatra<http://storify.com/KewGIS/kew-in-harapan-rainforest>
> Articles: Seeing the wood for the trees
> How Kew's GIS team and South East Asia botanists are working to help conserve and restore a rainforest in Sumatra. Download a pdf of this article here.<http://www.kew.org/ucm/groups/public/documents/document/kppcont_060602.pdf>
>
>
> ________________________________
> The Royal Botanic Gardens, Kew is a non-departmental public body with exempt charitable status, whose principal place of business is at Royal Botanic Gardens, Kew, Richmond, Surrey TW9 3AB, United Kingdom.
>
> The information contained in this email and any attachments is intended solely for the addressee(s) and may contain confidential or legally privileged information. If you have received this message in error, please return it immediately and permanently delete it. Do not use, copy or disclose the information contained in this email or in any attachment.
>
> Any views expressed in this email do not necessarily reflect the opinions of RBG Kew.
>
> Any files attached to this email have been inspected with virus detection software by RBG Kew before transmission, however you should carry out your own virus checks before opening any attachments. RBG Kew accepts no liability for any loss or damage which may be caused by software viruses.
> _______________________________________________
> Biomod-commits mailing list
> Biomod-commits at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/biomod-commits



More information about the Biomod-commits mailing list