2

I want to use the the makeEOO function from the redlistr package to calculate the Extent of Occurrence of 2 species ("binomial" A and B), starting from a shapefile with the corresponding distribution maps in form of polygons. To use the function, I need to convert the polygons into points. Here the starting shapefile.

I am using the sf package to import the shapefile

 library(sf)    
 dummy <- st_read(dsn = "Calculate_EOO_dummy/dummy_maps_dissolved.shp")
 plot(dummy)

enter image description here

I converted the polygons into multipoint features, and the multipoints into points

multi.p <- st_cast(dummy.diss, "MULTIPOINT")
my.points <- multi.p %>%  group_by(binomial) %>% st_cast("POINT")
plot(my.points)
my.points

enter image description here

> my.points
Simple feature collection with 33 features and 1 field
geometry type:  POINT
dimension:      XY
bbox:           xmin: -0.9471488 ymin: -0.9276773 xmax: 1.155772 ymax: 0.8080668
epsg (SRID):    4326
proj4string:    +proj=longlat +datum=WGS84 +no_defs
# A tibble: 33 x 2
# Groups:   binomial [2]
   binomial                 geometry
   <fct>                 <POINT [°]>
 1 A          (-0.5855355 0.7913769)
 2 A          (-0.5771905 0.7774687)
 3 A          (-0.2267038 0.5771905)
 4 A         (-0.3936022 0.05702364)
 5 A         (-0.1098748 -0.1015299)
 6 A          (0.02642559 -0.340751)
 7 A        (-0.02920723 -0.4464534)
 8 A         (-0.3824757 -0.4297636)
 9 A         (-0.8553547 -0.2878999)
10 A         (-0.9471488 -0.1182197)
# ... with 23 more rows

However, if I try to call the makeEOO function with my.points, I get an error:

eoo <- my.points %>% group_by(binomial) %>% makeEOO()

Error in makeEOO(my.points) : trying to get slot "coords" from an object (class "sf") that is not an S4 object.

How could I convert such polygons (separately for each species A and B) into points to use makeEOO?

1

The redlistr package depends on the sp package, and not on sf, there is an open issue on the package's GitHub about supporting sf, but has not been addressed yet. So what you should do is add a step where you convert your sf object into a SpatialPointsDataFrame object instead. Be careful though, you cannot apply dplyr verbs to sp objects. So you will probably need to split your data before using the makeEOO() function. This is how I would do it:

my.points.A <- my.points %>% filter(binomial == 'A') %>% as('Spatial')
my.points.B <- my.points %>% filter(binomial == 'B') %>% as('Spatial')
eoo.A <- my.points.A %>% makeEOO()
eoo.B <- my.points.A %>% makeEOO()
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.