Add XY points to raster map generated by levelplot

前端 未结 2 1487
不知归路
不知归路 2021-02-08 18:26

I have raster maps which are generated using the raster package in R. These raster layers can be visualized using the rasterVis package\'s

2条回答
  •  深忆病人
    2021-02-08 18:52

    So I had a dataframe with xy cordinates and so many z columns. This is the final answer to get points added to my map thanks to @jbaums:

    s <- stack(raster1,raster2)
    coordinates(SITES...TTEST) <- ~x+y # SpatialPointsDataFrame
    levelplot(s, layout=c(1, 2), 
              col.regions=colorRampPalette(c("darkred", "red3", 
                                             "orange", "yellow", "lightskyblue", "royalblue3", 
                                             "darkblue")),
              at=seq(floor(39.15945) ,ceiling(51.85068), length.out=30), 
              par.strip.text=list(cex=0),scales=list(alternating=FALSE))+
      layer(sp.points(SITES...TTEST, pch=ifelse(SITES...TTEST$Precip_DJF6 < 0.05, 2, 3), cex=2, col=1), rows=1) +
      layer(sp.points(SITES...TTEST, pch=ifelse(SITES...TTEST$Precip_DJF6 < 0.05, 2, 3), cex=2, col=1), rows=2)
    

提交回复
热议问题