@@ -215,10 +215,11 @@ cal_extract = function(tile_paths, gedi_grid, buffer = 12.5, fun = 'max', quiet
215
215
nrw = merge_tiles(grep(" _nw" , tile_paths , value = T ), " EPSG:25832" )
216
216
th = merge_tiles(grep(" _th_" , tile_paths , value = T ), " EPSG:25832" )
217
217
sn = merge_tiles(grep(" _sn" , tile_paths , value = T ), " EPSG:25833" )
218
+ bb = merge_tiles(grep(" _bb" , tile_paths , value = T ), " EPSG:25833" )
218
219
219
220
# extract
220
221
if (! quiet ) message(" Extracting..." )
221
- gedi32 = gedi33 = enrw = eth = esn = NULL
222
+ gedi32 = gedi33 = enrw = eth = esn = ebb = NULL
222
223
if (any(! is.null(nrw ), ! is.null(th ))){
223
224
gedi32 = sf :: st_transform(gedi_grid , sf :: st_crs(25832 )) | > sf :: st_buffer(buffer )
224
225
if (! is.null(nrw )){
@@ -230,13 +231,19 @@ cal_extract = function(tile_paths, gedi_grid, buffer = 12.5, fun = 'max', quiet
230
231
eth [is.nan(eth )] = NA
231
232
}
232
233
}
233
- if (! is.null(sn )){
234
+ if (any( ! is.null(sn ), ! is.null( bb ) )){
234
235
gedi33 = sf :: st_transform(gedi_grid , sf :: st_crs(25833 )) | > sf :: st_buffer(buffer )
235
- esn = terra :: extract(sn , terra :: vect(gedi33 ), fun = fun , ID = F )[,1 ] | > as.vector()
236
- esn [is.nan(esn )] = NA
236
+ if (! is.null(sn )){
237
+ esn = terra :: extract(sn , terra :: vect(gedi33 ), fun = fun , ID = F )[,1 ] | > as.vector()
238
+ esn [is.nan(esn )] = NA
239
+ }
240
+ if (! is.null(bb )){
241
+ ebb = terra :: extract(bb , terra :: vect(gedi33 ), fun = fun , ID = F )[,1 ] | > as.vector()
242
+ ebb [is.nan(ebb )] = NA
243
+ }
237
244
}
238
245
# merge
239
- gedi_grid $ ext_value = rowSums(cbind(enrw , eth , esn ), na.rm = T )
246
+ gedi_grid $ ext_value = rowSums(cbind(enrw , eth , esn , ebb ), na.rm = T )
240
247
gedi_grid = dplyr :: select(gedi_grid , dplyr :: everything(), dplyr :: starts_with(" geom" ))
241
248
attr(gedi_grid , " grid_type" ) = gtype
242
249
if (! quiet ) message(" Complete!" )
0 commit comments