BrunoVilela / letsR

Package letsR
http://brunovilela.github.io/letsR/
9 stars 3 forks source link

rgeos_PolyCreateComment: orphaned hole, cannot find containing polygon for hole at index 23 #8

Open rbfontana opened 1 year ago

rbfontana commented 1 year ago

Hi developers,

I'm trying to create a presence-absence matrix, but I'm having a problem. When I run my analysis the following error occurs, I've tried to fix it, but I can't.

biomes_abspres<-lets.presab.grid(shapes = anurans, grid = biomes, sample.unit = "id") Error in createPolygonsComment(p) : rgeos_PolyCreateComment: orphaned hole, cannot find containing polygon for hole at index 23 In addition: Warning message: In RGEOSBinPredFunc(spgeom1, spgeom2, byid, "rgeos_overlaps") : spgeom1 and spgeom2 have different proj4 strings


CODE

Load packages library(maptools) library(raster) library(letsR) library(rgdal)

Import shapefiles # All shp are SpatialPolygonsDataFrame class biomes<-readOGR("biomes_05.shp") # Biomes from New World according Olson. Shp with 27844 elements anurans<-readShapePoly("anurans.shp") # Shapefile of anurans from New World extracted from IUCN data with 3710 elements

Select by names anurans@data[["binomial"]]<-anurans@data[["sci_name"]]

Add projection to the anurans shp projection(anurans) <- projection(biomes)

Create PA matrix for biomes biomes_abspres<-lets.presab.grid(shapes = anurans, grid = biomes, sample.unit = "id")

BrunoVilela commented 11 months ago

Hi @rbfontana, could you try updating the package from Github. Also, try the updated code: http://brunovilela.github.io/letsR/articles/A-guide-to-transform-species-distributions-into-a-presence-absence-matrix-based.html From your error, your polygon seems to have a problem. But maybe it will work on the new version which was highly modified.