【问题标题】:Using BFAST to show breakpoints使用 BFAST 显示断点
【发布时间】:2021-10-23 17:13:27
【问题描述】:

我目前正在使用 bfastSpatial,我正在尝试将断点值绘制为基于年份颜色的图例。我知道 changeMonth 函数用于绘制基于月的断点 (http://www.loicdutrieux.net/bfastSpatial/) 但是,我正试图实现与 Morrison 等人类似的结果。 (2019)https://www.mdpi.com/2072-4292/10/7/1075 任何援助将不胜感激。

【问题讨论】:

    标签: r time-series raster trend r-modis


    【解决方案1】:

    如果要将断点日期四舍五入为整数年,可以使用floor,因为日期是十进制年。接下来,要制作与您展示的类似的图,您可以使用 tmap 包。由于您没有将任何数据附加到 OP,因此我使用了 bfastSpatial 包中包含的 tura 数据。

    library(bfastSpatial)
    library(tmap)
    
    # Load tura data
    data(tura)
    # Perform bfast analysis
    bfm <- bfmSpatial(tura, start=c(2009, 1), order=1)
    
    # Extract the first band (breakpoints)
    change <- bfm[[1]]
    
    # As breakpoints dates are in year decimals,
    # you can use floor to round them to lowest integer
    change <- floor(change)
    
    # Set shape as change, the object to plot
    tm_shape(change) +
      # Plot it as raster and set the palette, number of categories,
      # style (categorical) and title of the legend.
      tm_raster(palette = "Spectral",
                n = 5,
                style = "cat",
                title = "Year") +
      # Set the legend's position and eliminate the comma used by default for
      # separating thousands values. Add background color and transparency
      tm_layout(legend.position = c("right", "bottom"),
                legend.format=list(fun=function(x) formatC(x, digits=0, format="d")),
                legend.bg.color = "white",
                legend.bg.alpha = 0.7) +
      # Add scale bar, set position and other arguments
      tm_scale_bar(breaks = c(0,0.5,1),
                   position = c("right", "top"),
                   bg.color = "white",
                   bg.alpha = 0.7) +
      # Add north arrow with additional parameters
      tm_compass(type = "arrow", 
                 position = c("left", "top"),
                 bg.color = "white",
                 bg.alpha = 0.7) 
    

    得到的情节:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-22
      • 2018-05-04
      相关资源
      最近更新 更多