I am working on creating a species distribution model using R-INLA, and I want to use a shapefile(.shp) that I have created in ArcPro as a barrier in the spatial mesh. In order to do so, I think the shapefile must be in the 'SpatialPolygons' format.
When I read in the shapefile (which is made up of 6 polygons), using st_read(), it is imported as a SpatialPolygonsDataFrame (see attached pictures).
Additionally, i tried to get shapefiles using worldhire, thinned them and tried to remove all the extra wee islands, but the mesh wouldn't run on INLA.
Long story short, is there: a) A way I can import the .shp file as a SpatialPolygons object (would it need to be a separate shapefile for each polygon, or a different function)? b) A way I can convert the SpatialPolygonsDataFrame object to a SpatialPolygons object? c) Use a SpatialPolygonsDataFrame object when constructing a spatial autocorrelation mesh in R-INLA?
I appreciate any advice you can provide, please let me know if I can provide any more information
I'm not sure this will help regarding your underlying problem, but to create a Spatial* object from a Spatial*DataFrame, you use the
geometry()
function:That simply strips off all attribute columns from the SPDF.