ptitle / epm

An R package for the calculation of taxonomic, phenotypic and phylogenetic metrics across grid cells.
GNU General Public License v3.0
12 stars 3 forks source link

createEPMgrid with single table of coordinates #2

Closed jenifferteles closed 1 year ago

jenifferteles commented 1 year ago

Hello, I’m trying to create a createEPMgrid object with my occurring points. But in the examples in the pdf of the package, I’m not getting because when creating the createEPMgrid it does with the raw data of "spOccList" and not with the created object called "spOccList3" as in the case below. How can I fix this? Thank you

single table of coordinates

spOccList3 <- spOccList2 for (i in 1:length(spOccList3)) { spOccList3[[i]] <- cbind.data.frame(taxon = names(spOccList3)[i], spOccList3[[i]]) colnames(spOccList3[[i]]) <- c('taxon', 'X', 'Y') } spOccList3 <- do.call(rbind, spOccList3) rownames(spOccList3) <- NULL spOccList3[, "taxon"] <- as.character(spOccList3[, "taxon"]) tamiasEPM <- createEPMgrid(spOccList, resolution = 100000, cellType = 'square')

ptitle commented 1 year ago

Hi, I fixed a problem and also corrected some mistakes in the example code from createEPMgrid(). Please install from github with remotes::install_github('ptitle/epm') and try again and let me know if this solves your issue!

jenifferteles commented 1 year ago

Thank you, one last question in the crs part I tried to put only the code I need (crs = 4674), but gives the following error:

Detected 119 taxa with point data. Error in createEPMgrid(dataOK, resolution = 1e+05, cellType = "square", : Input data are in longlat, therefore resolution must be in decimal degrees.

Do I necessarily need a SpatRaster file to copy crs as the example?

I used the following command for #single table of coordinates :

CriarEPM <- createEPMgrid(dataOK, resolution = 100000, cellType = 'square', crs = 4674)

Thank you so much!!!

ptitle commented 1 year ago

Hi, No, you can provide the crs directly as a code, such as crs = 4674. The problem here is that your coordinates are in longitude/latitude, and you provided a resolution of 100k. The resolution is assumed to be in the same units as the coordinates. So you should either transform your coordinates into a projected system in meters, or provide the resolution in decimal degree units. Make sense?

jenifferteles commented 1 year ago

Yeah Totally! Perfect, thank you so much!

ptitle commented 1 year ago

Great, good to hear this makes sense. Please post any other issues!