I would like to use a 2D map of the world that I already created to build a 3D map in which the height of every country (as a polygon) is linked to a specific integer number (coming from a cluster analysis) and colour the country in relation to the political system (that I have in my data). To create the 2D map I used this library with:
library("rnaturalearth")
library("rnaturalearthdata")
mapdata <- map_data("world")
I left join with my dataset and I have:
long lat group order Country_name subregion Code Region Politicalsystem Cluster
1 -69.89912 12.45200 1 1 Aruba <NA> ABW Latin America & Caribbean Constitutional parliamentary monarchy 1
2 -69.89571 12.42300 1 2 Aruba <NA> ABW Latin America & Caribbean Constitutional parliamentary monarchy 1
3 -69.94219 12.43853 1 3 Aruba <NA> ABW Latin America & Caribbean Constitutional parliamentary monarchy 1
4 -70.00415 12.50049 1 4 Aruba <NA> ABW Latin America & Caribbean Constitutional parliamentary monarchy 1
5 -70.06612 12.54697 1 5 Aruba <NA> ABW Latin America & Caribbean Constitutional parliamentary monarchy 1
6 -70.05088 12.59707 1 6 Aruba <NA> ABW Latin America & Caribbean Constitutional parliamentary monarchy 1
To create the 2D map:
ma2<-ggplot(maptest, aes( x = long, y = lat, group=group)) +
geom_polygon(aes(fill = as.factor(Cluster)), color = "black")
x11()
map
I am trying to use the library: rayshader
and ggplot2
in order to change the map in 3D but I'm facing several issues, how I can do it?