【问题标题】:spplot legend with point rather than with scale带点而不是带比例的 spplot 图例
【发布时间】:2023-01-12 00:52:27
【问题描述】:

我正在根据 INLA 预测创建一个情节。一切都非常适合建模,但对于情节,图上的图例是点(如https://gis.stackexchange.com/questions/350918/how-do-i-reverse-spplot-colour-key-so-the-values-are-decreasing)而不是比例尺(如此处http://www.nickeubank.com/wp-content/uploads/2015/10/RGIS3_MakingMaps_part1_mappingVectorData.html):

这是我想更改的代码。我想有一个因素(R spplot: colorbar rather than legend for SpatialPoint dataspplot issue with legend range and colors distribution)的问题,但我不明白如何/改变什么:

m_grid <- inla(formWITHOUT, data = inla.stack.data(region.stack.predGrid, spde = inlaSetting$region.spde),
          family = "gamma",
          control.predictor = list(A = inla.stack.A(region.stack.predGrid), compute = TRUE, link=1),
          control.compute = list(cpo = TRUE, dic = TRUE),
          control.family=list(link="default"))

summary(m_grid)

index.pred <- inla.stack.index(region.stack.predGrid, "region.pred")$data

region.grid_sf$Sbiomass <- m_grid$summary.fitted.values[index.pred, "mean"]
region.grid_sf$Sbiomass_sd <- m_grid$summary.fitted.values[index.pred, "sd"]

my.palette <- brewer.pal(n = 7, name = "OrRd")

par(mar = c(0,0,0,0))
spplot(region.grid_sf, c("Sbiomass"), col.regions = my.palette, col = "transparent")

提前感谢任何提示!

【问题讨论】:

  • 似乎 (edzer.github.io/sp/#using-lattice-plot-spplot) 图例将使用点符号表示空间点,并使用所需的颜色条表示栅格或多边形。您可以尝试将点数据转换为栅格(例如通过克里金法)或多边形(例如 Voronoi 或矩形网格)。
  • 谢谢 !我会尽力让你知道!
  • 实际上答案比我想的更简单:添加“colorkey =T”作为参数:D
  • 您能否将其作为您自己问题的答案并将其标记为“已接受的答案”(以便未来的用户可以将其识别为已解决的问题)?谢谢! :-)

标签: r sp


【解决方案1】:

我终于找到了答案:

cuts <- c(0,5000,10000,15000,20000,25000,30000)

spplot(region.grid_sf, 
       c("Sbiomass"), 
       col.regions = my.palette, 
       col = "transparent",
       key.space = list(x=0.1,y=0.3),
       colorkey  =T,
       cuts = cuts, 
       cex = 2, 
       pch = 22)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-19
    • 1970-01-01
    • 1970-01-01
    • 2019-09-06
    • 2016-02-24
    • 1970-01-01
    • 2020-09-07
    相关资源
    最近更新 更多