2

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

Link to image of shapefile plotted using plot() function

Link to image of the SpatialPolygonsDataFrame

1 Answer 1

1

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:

library(sp)
library(rgdal)
seas = readOGR("il_seas.shp")

class(seas)
[1] "SpatialPolygonsDataFrame"
attr(,"package")
[1] "sp"
> seas_geom = geometry(seas)
> class(seas_geom)
[1] "SpatialPolygons"
attr(,"package")
[1] "sp"

That simply strips off all attribute columns from the SPDF.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.