'R: Use real lon/lat values at x and y axis

I've generated the following chart with R:

library(rnaturalearth)
library(rnaturalearthdata)
library(ggplot2)
library(rworldmap)
library(scales)
library(sf)
library(mapdata)
library(maptools)
library(ggthemes)

data(wrld_simpl)

antarctica <- wrld_simpl[wrld_simpl$NAME == "Antarctica", ]
pr <- "+proj=laea +lat_0=-90 +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0"
antarctica.laea <- spTransform(antarctica, CRS(pr))

antarctica_plot <- ggplot() +
  geom_polygon(data = antarctica.laea, aes(x=long, y=lat, group=group), fill = '#003f5c') +
  labs( x = "Longitude", y = "Latitude") +
  annotation_scale(location = "bl", width_hint = 0.5) +
  annotation_north_arrow(location = "bl", which_north = "true", 
                         pad_x = unit(0.75, "in"), pad_y = unit(0.5, "in"),
                         style = north_arrow_fancy_orienteering) +
  theme_wsj()

antarctica_plot

Antarctica map

How can I display the real latitude and longitude values on my axis?



Solution 1:[1]

You can solve this transforming the spatial polygon (sp) to simple feature class (sf) and using the geom_sf instead geom_polygon. I couldnt find the functions annotation_scale and annotation_north_arrow in any of those packages btw...

antarctica.laea <- st_as_sf(antarctica.laea)
        
    ggplot(antarctica.laea) +
      geom_sf(aes(), fill = '#003f5c')+
      labs( x = "Longitude", y = "Latitude") +
      theme_wsj()

enter image description here

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