I'm trying to use Resolve ecoregion data to map the biomes of the African continent. The shapefile is global, and there are over 800 polygons, as each polygon represents a unique ecological area (whereas there are only seven terrestrial biomes, biomes are the larger spatial unit and are composed of similar ecological areas). Perhaps because of the data size or number of polygons, I am having a difficult time producing a map using tmap.
I first cropped the shapefile to the African continent:
resolve = st_read("Data/Ecoregions2017/Ecoregions2017.shp")
Africa = st_read("Data/Africa_SHP/Africa/Africa.shp")
st_crs(Africa) = crs(resolve)
resolveAfrica =st_intersection(st_make_valid(resolve), st_make_valid(Africa))
But when I try to then map this cropped shapefile:
tm_shape(Africa) + tm_borders() +
tm_shape(resolveAfrica) + tm_fill("BIOME_NAME")
R returns an error:
Error in vapply(lst, class, rep(NA_character_, 3)) :
values must be length 3,
but FUN(X[[56]]) result is length 2
Does anyone know what steps I can take to address this error?
tmap
works perfectly. So either its related to your Africa shape (which might be the same as mine?) or your versions of everything. I'm sf:0.9.6 tmap:3.2 R:4.0.3