1

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?

Yuhan Wang
  • 11
  • 1

1 Answers1

0

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

MJ313
  • 75
  • 1
  • 1
  • 7