0

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?

AndrewGB
  • 16,126
  • 5
  • 18
  • 49
TheGrown
  • 3
  • 3
  • https://medium.com/datascape/data-on-a-3d-world-map-cbe3702dbe67 – IRTFM Dec 29 '21 at 03:20
  • thanks but is not i'm looking for, i would like to plot not the sphere but a map with the third dimension as cluster number – TheGrown Dec 29 '21 at 13:19
  • perhaps you want a chloropleth map? (You should use dput to offer that data object. It's a bitch to load data that has lots of spaces and punctuation in it without proper separators.And do test your code with only the listed packages loaded. I'm getting Error in map_data("world") : could not find function "map_data" which indicates there's another package that han't been loaded. – IRTFM Dec 29 '21 at 15:47
  • i think i miss to write this two library: library("sf") library("ggplot2") – TheGrown Dec 29 '21 at 16:20

0 Answers0