根据纬度将标签放在栅格地图上

时间:2018-04-03 12:38:37

标签: r ggplot2 label raster

<div class="responsive">
  <div class="gallery center-block">
    <a target="_blank" href="https://s20.postimg.org/eaz0ihd0d/usb3.png">
      <img src="https://s20.postimg.org/eaz0ihd0d/usb3.png" alt="image of bluetooth 4.0 usb adapter dongle" width="100%" height="auto">
    </a>
  </div>
</div>

enter image description here

有没有办法根据纬度在上面的图像上放置标签。例如,低于-10的纬度有一个标签,-10到0之间有另一个标签,依此类推。如下所示:

enter image description here

1 个答案:

答案 0 :(得分:1)

绘制栅格与任何其他基础绘图非常相似。所以你可以修改图形,就像任何其他情节一样:

# data
library(raster)
dat <- getData('worldclim', var='tmin', res=10)

# define y locations for labels and lines

y <- seq(-20,20,by = 10)

# plot and suppress y axis (use axes=FALSE if you don't want either)

plot(dat$tmin1,yaxt="n")

# add labels 

axis(2, at=y,labels=sprintf('%s deg. lat.',y), col.axis="darkgreen", las=2)

# add lines

abline(h=y,col='red',lty=2)

enter image description here