Parsimonious way to add north arrow and scale bar to ggmap

前端 未结 2 1115
一整个雨季
一整个雨季 2021-01-02 09:35

I am trying to use ggmap to create a map of the protected areas I am working in with a satellite image from google earth underneath. I can make a very satisfactory image ex

2条回答
  •  时光说笑
    2021-01-02 09:56

    It looks like map.scale and north.arrow are designed to work with base graphics, but ggplot uses grid graphics. I'm not that familiar with graphing spatial data, but as a quick hack for the North arrow, the code below includes two different options:

    ggmap(map, extent= "device") +
      geom_segment(arrow=arrow(length=unit(3,"mm")), aes(x=33.5,xend=33.5,y=-2.9,yend=-2.6), 
                   colour="yellow") +
      annotate(x=33.5, y=-3, label="N", colour="yellow", geom="text", size=4) +
      geom_segment(arrow=arrow(length=unit(4,"mm"), type="closed", angle=40), 
                   aes(x=33.7,xend=33.7,y=-2.7,yend=-2.6), colour=hcl(240,50,80)) +
      geom_label(aes(x=33.7, y=-2.75, label="N"),
                 size=3, label.padding=unit(1,"mm"), label.r=unit(0.4,"lines"))  
    

提交回复
热议问题