'Error in tmap projection: invalid crs: hd

When I try to draw a map with a Hobo–Dyer projection, it told me:

Error in st_crs.character(x[[shape.id[masterID]]]$projection) : invalid crs: hd

Here is my code:

tm_shape(countries_spdf, projection = "hd") +
  tm_grid(n.x = 11, n.y = 11) +
  tm_fill(col = "population", style = "quantile")  +
  tm_borders(col = "burlywood4") 

What should I do?



Solution 1:[1]

I believe the projection feature of tm_shape has been changed to only take on integers representing the desired CRS. i.e. it still works with 4326, which is the most common one in the industry. However there is workaround using coord_map from ggplot library which I have included below:

tm_shape(countries_spdf, projection = 4326) +
  tm_grid(n.x = 11, n.y = 11) +
  tm_fill(col = "population", style = "quantile")  +
  tm_borders(col = "burlywood4")

tm_shape(countries_spdf, projection = coord_map("hr")) +
  tm_grid(n.x = 11, n.y = 11) +
  tm_fill(col = "population", style = "quantile")  +
  tm_borders(col = "burlywood4")

Hope this helps

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MJ313