macroecology / letsR

Tools for data handling and analysis in macroecology
http://brunovilela.github.io/letsR/
28 stars 7 forks source link

Error in y[i, ] : cannot get a slot ("Polygons") from an object of type "NULL" #12

Open Marialejandra opened 1 year ago

Marialejandra commented 1 year ago

Hola Bruno y Fabricio! I am getting this error when I try to run lets.presab:

Error in y[i, ] : cannot get a slot ("Polygons") from an object of type "NULL"

This is what I am trying to run:

Import the shapefile data

helio <- readShapePoly("data_0.shp", delete_null_obj = TRUE)

Transform anuran polygons into a global PAM

pam_helio <- lets.presab(helio, resol = 1)

Call the object

pam_helio

Summary of the PAM

summary(pam_helio)

The file data_0.shp is a shape file that I downloaded from IUCN (Range data Polygons SHP).

Can you help with this? Thank you :)

fabro commented 1 year ago

Hi Marialejandra,

Thanks for the interest in our package. It seems that the polygons were not properly read/loaded. Could you share that file so we can check and try to reproduce the error?

Marialejandra commented 1 year ago

Hola Fabricio! Thank you for answering so quickly! I am enjoying your package; pretty cool. Here is the file that I used. Fabricio, I have a question. I created shapes of the geographical distribution of the taxa that I am currently studying. Can I use those shapefiles instead of the IUCN files? Thank you. redlist_species_data_bea7543e-1bdc-4501-8ec3-5dd3cdaf4b01 (1).zip

fabro commented 1 year ago

Gracias, Marialejandra.

The error has to do with the column name of the species. As explained in the help: "Species names should be in a column (within the .DBF table of the shapefile) called BINOMIAL/binomial or SCINAME/sciname." In your case, this was "SCI_NAME", hence the error.

Yes, you can use any other shapefiles. As long as you keep the same structure (a shapefile with all polygons/species of interest) and have that column name (BINOMIAL/binomial or SCINAME/sciname).

Marialejandra commented 1 year ago

Gracias Fabricio! I edited the DBF file and changed the name of the column. However, I am having a different error: Error in getinfo.shape(filen) : Error opening SHP file. I tried with Anura (the taxa in the script) and I am getting the same error.