Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何利用WorldClim数据计算R中的热指数_R_Gis - Fatal编程技术网

如何利用WorldClim数据计算R中的热指数

如何利用WorldClim数据计算R中的热指数,r,gis,R,Gis,是否有一种在R中使用WorldClim数据绘制全球变暖指数的方法 对于那些不熟悉温暖指数的人来说,这是一个由Yim&Kira编写的方程,用来描述生长期的长度和强度,请参见: 我的例子:我有一个植物种群位置的数据集,其中我使用WorldClim数据得出每个位置的月平均温度,并在tibble中描述它们: ## # A tibble: 5 x 18 ## species latitude longitude temp_1 temp_2 temp_3 temp_4 temp_5 temp_6 ##

是否有一种在R中使用WorldClim数据绘制全球变暖指数的方法

对于那些不熟悉温暖指数的人来说,这是一个由Yim&Kira编写的方程,用来描述生长期的长度和强度,请参见:

我的例子:我有一个植物种群位置的数据集,其中我使用WorldClim数据得出每个位置的月平均温度,并在tibble中描述它们:

## # A tibble: 5 x 18
##   species latitude longitude temp_1 temp_2 temp_3 temp_4 temp_5 temp_6
##   <chr>      <dbl>     <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>
## 1 Magnol…     31.0     -91.5   9.05  11.1   15.5   19.6    23.1   26.3
## 2 Magnol…     35.7     -93.2   2.45   4.89  10.2   15.5    19.5   23.8
## 3 Magnol…     35.7     -93.2   2.45   4.89  10.2   15.5    19.5   23.8
## 4 Magnol…     43.2     -76.3  -5.33  -4.55   0.98   7.42   13.7   18.5
## 5 Magnol…     35.6     -92.9   2.45   4.89  10.2   15.5    19.5   23.8
## # … with 9 more variables: temp_7 <dbl>, temp_8 <dbl>, temp_9 <dbl>,
## #   temp_10 <dbl>, temp_11 <dbl>, temp_12 <dbl>, valid_cells <dbl>,
## #   warmth_index <dbl>, row_id <int>
####tible:5 x 18
##物种纬度经度温度1温度2温度3温度4温度5温度6
##                          
##1 Magnol…31.0-91.5 9.05 11.1 15.5 19.6 23.1 26.3
##2 Magnol…35.7-93.2 2.45 4.89 10.2 15.5 19.5 23.8
##3 Magnol…35.7-93.2 2.45 4.89 10.2 15.5 19.5 23.8
##4马格诺…43.2-76.3-5.33-4.55 0.98 7.42 13.7 18.5
##5马格诺…35.6-92.9 2.45 4.89 10.2 15.5 19.5 23.8
###…还有9个变量:temp_7,temp_8,temp_9,
##临时单元10、临时单元11、临时单元12、有效单元,
###温暖指数,行id
然后将数据从宽改为长:

reshaped_data <- raw_data %>%
    tidyr::gather(key = "month", value = "temp", temp_1:temp_12) %>%
    mutate(month = stringr::str_remove(month, "temp_") %>% readr::parse_number(),
           warm = case_when(temp > 5 ~ TRUE,
                            TRUE ~ FALSE))
重塑的_数据%
tidyr::收集(key=“month”、value=“temp”、temp\u 1:temp\u 12)%>%
mutate(month=stringr::str_remove(month,“temp_”)%%>%readr::parse_number(),
温暖=当(温度>5)为真时,
对~错)
利用Yim&Kira的方程,一位同事写了以下内容来计算每个位置的温暖指数:

warmth_index <- function(warm, temp){
    warm_months <- sum(warm)
    temp_sum <- sum(warm * temp) # when multiplied, the warm logical vector becomes 0 & 1
    temp_sum - (5 * warm_months)
}

u索引请添加给定数据集的预期输出。您还可以使用
dput
功能添加数据,而不是粘贴数据directly@PoGibas抱歉,预期输出将是一个曲线图,显示全球变暖指数的变化。我正试图用r来做地理信息系统,并希望将地块的温暖指数从低到高进行分级。我一直在使用raster::plot这种方法,但我希望使用简单的热图来绘制温暖指数,而不是温度min/max/mean。看这里@M-M我不明白?这里的问题不是关于地点,而是如何结合WorldClim提供的所有月平均温度,对其应用温暖指数计算,然后绘制世界上每个地点的全球温暖指数。。。我不认为热图是我想要的?对不起,我没说清楚earlier@Harry你必须澄清你的问题。我个人很难理解这一点。不要留下评论。并尝试解释到底需要什么,最好显示步骤和最终预期输出请为给定数据集添加预期输出。您还可以使用
dput
功能添加数据,而不是粘贴数据directly@PoGibas抱歉,预期输出将是一个曲线图,显示全球变暖指数的变化。我正试图用r来做地理信息系统,并希望将地块的温暖指数从低到高进行分级。我一直在使用raster::plot这种方法,但我希望使用简单的热图来绘制温暖指数,而不是温度min/max/mean。看这里@M-M我不明白?这里的问题不是关于地点,而是如何结合WorldClim提供的所有月平均温度,对其应用温暖指数计算,然后绘制世界上每个地点的全球温暖指数。。。我不认为热图是我想要的?对不起,我没说清楚earlier@Harry你必须澄清你的问题。我个人很难理解这一点。不要留下评论。并试图解释到底需要什么,最好显示步骤和最终预期输出
ma.t.MIN <- calc(ma.t.min, min)
ma.t.MAX <- calc(ma.t.max, max)