Skip to contents

Calculates the predicted abundance by multiplying the density prediction values by prediction polygon areas

Usage

model_abundance(x, dens.idx, sum.abund = TRUE)

Arguments

x

object of class sf; SDM with density predictions. Must have a valid crs code

dens.idx

name or index of column(s) in x with density predictions. Can be a character vector (column names) or numeric vector (column indices)

sum.abund

logical; whether or not to sum all of the predicted abundances

Value

If sum.abund == TRUE, then a vector of the same length as dens.idx

representing the predicted abundance for the density values in each column.

If sum.abund == FALSE and the length of dens.idx is 1, then a numeric vector with the predicted abundance of each prediction polygon of x.

If sum.abund == FALSE and the length of dens.idx is greater than 1, then a data frame with length(dens.idx) columns of the predicted abundance of prediction polygons

Details

Multiplies the values in the specified column(s) (i.e. the density predictions) by the area in square kilometers of their corresponding prediction polygon. The area of each prediction polygon is calculated using st_area from geos_measures. x must have a valid crs code to calculate area for these abundance calculations.

Examples

model_abundance(preds.1, "Density")
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#>  Density 
#> 113798.7 
model_abundance(preds.1, c(1, 1))
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#> [1] 113798.7 113798.7
model_abundance(preds.1, c(1, 1), FALSE)
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#> old-style crs object detected; please recreate object with a recent sf::st_crs()
#>         1.abund     1.abund
#> 1     29.715617   29.715617
#> 2      9.213089    9.213089
#> 3     21.618285   21.618285
#> 4      9.510542    9.510542
#> 5     11.992925   11.992925
#> 6     15.309244   15.309244
#> 7      7.692235    7.692235
#> 8      9.466167    9.466167
#> 9     13.958726   13.958726
#> 10    48.309506   48.309506
#> 11    81.283063   81.283063
#> 12    37.782909   37.782909
#> 13    21.123915   21.123915
#> 14    29.372347   29.372347
#> 15   308.682325  308.682325
#> 16   511.227249  511.227249
#> 17   558.302197  558.302197
#> 18   654.233399  654.233399
#> 19   438.531888  438.531888
#> 20   142.804115  142.804115
#> 21   393.110499  393.110499
#> 22   496.567451  496.567451
#> 23   639.749943  639.749943
#> 24   670.310612  670.310612
#> 25   251.498152  251.498152
#> 26    49.120715   49.120715
#> 27    51.353557   51.353557
#> 28    21.130448   21.130448
#> 29    18.536482   18.536482
#> 30    14.267988   14.267988
#> 31    14.665388   14.665388
#> 32    33.444843   33.444843
#> 33    25.682155   25.682155
#> 34    59.543802   59.543802
#> 35   102.139409  102.139409
#> 36   162.003138  162.003138
#> 37    31.567839   31.567839
#> 38    60.792942   60.792942
#> 39   440.005881  440.005881
#> 40   978.828473  978.828473
#> 41   970.317661  970.317661
#> 42   959.576708  959.576708
#> 43  1076.442113 1076.442113
#> 44   526.980160  526.980160
#> 45   492.093378  492.093378
#> 46   500.778242  500.778242
#> 47  1178.278788 1178.278788
#> 48  1266.595181 1266.595181
#> 49   831.628443  831.628443
#> 50   724.295329  724.295329
#> 51    48.423352   48.423352
#> 52    22.295281   22.295281
#> 53    13.507420   13.507420
#> 54    13.379502   13.379502
#> 55     7.992948    7.992948
#> 56    13.302392   13.302392
#> 57     4.609331    4.609331
#> 58    42.006974   42.006974
#> 59    53.911134   53.911134
#> 60   134.721655  134.721655
#> 61   278.000058  278.000058
#> 62    62.138648   62.138648
#> 63   767.120262  767.120262
#> 64  1022.332185 1022.332185
#> 65  1099.977261 1099.977261
#> 66  1319.306666 1319.306666
#> 67  1264.580888 1264.580888
#> 68  1025.781614 1025.781614
#> 69  1074.996881 1074.996881
#> 70   568.203313  568.203313
#> 71   463.107393  463.107393
#> 72   846.578824  846.578824
#> 73  1007.831360 1007.831360
#> 74  1395.035148 1395.035148
#> 75           NA          NA
#> 76    49.212468   49.212468
#> 77    14.911804   14.911804
#> 78     5.148820    5.148820
#> 79     4.751022    4.751022
#> 80    16.470810   16.470810
#> 81    22.149293   22.149293
#> 82     6.200892    6.200892
#> 83    63.827365   63.827365
#> 84   183.396771  183.396771
#> 85   333.697073  333.697073
#> 86    75.974646   75.974646
#> 87   660.710544  660.710544
#> 88  1137.094612 1137.094612
#> 89  1257.932145 1257.932145
#> 90  1177.211844 1177.211844
#> 91  1373.445558 1373.445558
#> 92  1051.430914 1051.430914
#> 93  1099.757383 1099.757383
#> 94   619.586870  619.586870
#> 95   644.800174  644.800174
#> 96  1021.594018 1021.594018
#> 97  1004.579364 1004.579364
#> 98  1199.583989 1199.583989
#> 99           NA          NA
#> 100          NA          NA
#> 101  100.022644  100.022644
#> 102   20.635956   20.635956
#> 103    2.824256    2.824256
#> 104    2.987275    2.987275
#> 105    8.516881    8.516881
#> 106   28.702889   28.702889
#> 107   68.487057   68.487057
#> 108  160.860509  160.860509
#> 109   49.637587   49.637587
#> 110  232.696212  232.696212
#> 111  351.478354  351.478354
#> 112 1373.818991 1373.818991
#> 113 1253.029767 1253.029767
#> 114  993.052475  993.052475
#> 115 1105.857212 1105.857212
#> 116  835.864881  835.864881
#> 117 1208.419795 1208.419795
#> 118  800.214380  800.214380
#> 119  601.473113  601.473113
#> 120 1132.563715 1132.563715
#> 121 1252.130124 1252.130124
#> 122 1364.994320 1364.994320
#> 123 1338.141997 1338.141997
#> 124          NA          NA
#> 125          NA          NA
#> 126   93.047002   93.047002
#> 127   31.513009   31.513009
#> 128    1.278419    1.278419
#> 129    1.442568    1.442568
#> 130   11.104454   11.104454
#> 131   58.667886   58.667886
#> 132  125.421544  125.421544
#> 133   76.570231   76.570231
#> 134  106.446194  106.446194
#> 135  196.353341  196.353341
#> 136 1026.383055 1026.383055
#> 137 1202.606515 1202.606515
#> 138 1066.236304 1066.236304
#> 139 1053.705248 1053.705248
#> 140          NA          NA
#> 141  625.572900  625.572900
#> 142  794.363420  794.363420
#> 143 1136.983703 1136.983703
#> 144 1055.066502 1055.066502
#> 145 1198.866303 1198.866303
#> 146 1423.354324 1423.354324
#> 147 1412.950043 1412.950043
#> 148 1287.174988 1287.174988
#> 149          NA          NA
#> 150          NA          NA
#> 151   73.927147   73.927147
#> 152   40.608258   40.608258
#> 153    3.911921    3.911921
#> 154    4.826559    4.826559
#> 155   29.511036   29.511036
#> 156   29.090951   29.090951
#> 157   79.000370   79.000370
#> 158  184.715596  184.715596
#> 159  149.972945  149.972945
#> 160  220.692526  220.692526
#> 161 1278.343687 1278.343687
#> 162  862.485401  862.485401
#> 163  668.024648  668.024648
#> 164  703.981623  703.981623
#> 165  538.206654  538.206654
#> 166  807.861409  807.861409
#> 167 1129.229716 1129.229716
#> 168 1213.738385 1213.738385
#> 169 1323.688759 1323.688759
#> 170 1388.788602 1388.788602
#> 171 1429.053497 1429.053497
#> 172          NA          NA
#> 173          NA          NA
#> 174          NA          NA
#> 175          NA          NA
#> 176  118.826124  118.826124
#> 177   18.126000   18.126000
#> 178   15.503924   15.503924
#> 179   14.565953   14.565953
#> 180   35.863013   35.863013
#> 181  110.352073  110.352073
#> 182  124.998841  124.998841
#> 183   28.674313   28.674313
#> 184   31.210789   31.210789
#> 185   92.093086   92.093086
#> 186  259.011161  259.011161
#> 187  684.888184  684.888184
#> 188  993.540657  993.540657
#> 189  639.701251  639.701251
#> 190  658.528890  658.528890
#> 191 1065.183102 1065.183102
#> 192 1277.160231 1277.160231
#> 193 1361.309875 1361.309875
#> 194 1182.433710 1182.433710
#> 195          NA          NA
#> 196          NA          NA
#> 197          NA          NA
#> 198          NA          NA
#> 199          NA          NA
#> 200          NA          NA
#> 201  123.686541  123.686541
#> 202  145.158254  145.158254
#> 203   48.059915   48.059915
#> 204   60.376694   60.376694
#> 205   81.531444   81.531444
#> 206  108.482756  108.482756
#> 207   63.794913   63.794913
#> 208   20.424917   20.424917
#> 209   33.365174   33.365174
#> 210   88.599356   88.599356
#> 211  299.001466  299.001466
#> 212          NA          NA
#> 213 1399.331236 1399.331236
#> 214          NA          NA
#> 215 1201.343099 1201.343099
#> 216 1146.204760 1146.204760
#> 217  900.185848  900.185848
#> 218  739.162367  739.162367
#> 219 1332.832473 1332.832473
#> 220          NA          NA
#> 221          NA          NA
#> 222          NA          NA
#> 223          NA          NA
#> 224          NA          NA
#> 225          NA          NA
#> 226  148.446042  148.446042
#> 227  277.553154  277.553154
#> 228   97.285115   97.285115
#> 229   90.077503   90.077503
#> 230  139.699024  139.699024
#> 231  102.850340  102.850340
#> 232   18.272389   18.272389
#> 233   44.728180   44.728180
#> 234   92.015905   92.015905
#> 235  579.437580  579.437580
#> 236  829.655848  829.655848
#> 237 1192.986975 1192.986975
#> 238 1302.456927 1302.456927
#> 239 1383.676632 1383.676632
#> 240 1399.189922 1399.189922
#> 241          NA          NA
#> 242          NA          NA
#> 243          NA          NA
#> 244          NA          NA
#> 245          NA          NA
#> 246          NA          NA
#> 247          NA          NA
#> 248          NA          NA
#> 249          NA          NA
#> 250          NA          NA
#> 251  219.868673  219.868673
#> 252  253.205760  253.205760
#> 253  161.427434  161.427434
#> 254  233.535451  233.535451
#> 255  164.052272  164.052272
#> 256   30.900163   30.900163
#> 257   83.103166   83.103166
#> 258  108.881843  108.881843
#> 259  229.842418  229.842418
#> 260  356.776908  356.776908
#> 261          NA          NA
#> 262          NA          NA
#> 263          NA          NA
#> 264          NA          NA
#> 265          NA          NA
#> 266          NA          NA
#> 267          NA          NA
#> 268          NA          NA
#> 269          NA          NA
#> 270          NA          NA
#> 271          NA          NA
#> 272          NA          NA
#> 273          NA          NA
#> 274          NA          NA
#> 275          NA          NA
#> 276  221.746544  221.746544
#> 277  332.734815  332.734815
#> 278  213.490583  213.490583
#> 279  243.151612  243.151612
#> 280   63.738572   63.738572
#> 281  147.348113  147.348113
#> 282  700.197309  700.197309
#> 283  972.696869  972.696869
#> 284  534.312367  534.312367
#> 285  632.582664  632.582664
#> 286          NA          NA
#> 287          NA          NA
#> 288          NA          NA
#> 289          NA          NA
#> 290          NA          NA
#> 291          NA          NA
#> 292          NA          NA
#> 293          NA          NA
#> 294          NA          NA
#> 295          NA          NA
#> 296          NA          NA
#> 297          NA          NA
#> 298          NA          NA
#> 299          NA          NA
#> 300          NA          NA
#> 301   95.561780   95.561780
#> 302  126.699175  126.699175
#> 303   52.809529   52.809529
#> 304   41.876884   41.876884
#> 305    9.223000    9.223000
#> 306  120.776751  120.776751
#> 307  241.916685  241.916685
#> 308  477.663640  477.663640
#> 309  307.556457  307.556457
#> 310  214.001827  214.001827
#> 311          NA          NA
#> 312          NA          NA
#> 313          NA          NA
#> 314          NA          NA
#> 315          NA          NA
#> 316          NA          NA
#> 317          NA          NA
#> 318          NA          NA
#> 319          NA          NA
#> 320          NA          NA
#> 321          NA          NA
#> 322          NA          NA
#> 323          NA          NA
#> 324          NA          NA
#> 325          NA          NA