R语言学习记录:rasterVis包绘制栅格时叠加矢量
在绘制栅格的时候往往需要叠加一个矢量底图上去,看起来会更美观,更清晰。
在作者的官方网站上,他是这么指导的,
The result of the last call is a trellis
object. The latticeExtra package provides the layer
function to add contents. For example, let’s add the administrative borders. This information is available at the GADM service.

实测不好使,太麻烦!
用这个
总结一下就是:先用sf读取,然后用as(st_geometry(sf读取的shp), Class="Spatial")把它转化为rasterVis包可以识别的矢量格式。

碎碎念:这个包还是有很大缺陷的,作者虽然也还在维护,但是基于lattice的框架很难让人操作,而且作者这个帮助文档写的稀烂,随意引用。


AI还是YYDS!