Skip to content

Commit 680a775

Browse files
committed
support Brandenburg ALS in cal_extract()
1 parent ed182c0 commit 680a775

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

R/location_calibration.R

+12-5
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,11 @@ cal_extract = function(tile_paths, gedi_grid, buffer = 12.5, fun = 'max', quiet
215215
nrw = merge_tiles(grep("_nw", tile_paths, value = T), "EPSG:25832")
216216
th = merge_tiles(grep("_th_", tile_paths, value = T), "EPSG:25832")
217217
sn = merge_tiles(grep("_sn", tile_paths, value = T), "EPSG:25833")
218+
bb = merge_tiles(grep("_bb", tile_paths, value = T), "EPSG:25833")
218219

219220
# extract
220221
if (!quiet) message("Extracting...")
221-
gedi32 = gedi33 = enrw = eth = esn = NULL
222+
gedi32 = gedi33 = enrw = eth = esn = ebb = NULL
222223
if (any(!is.null(nrw), !is.null(th))){
223224
gedi32 = sf::st_transform(gedi_grid, sf::st_crs(25832)) |> sf::st_buffer(buffer)
224225
if (!is.null(nrw)){
@@ -230,13 +231,19 @@ cal_extract = function(tile_paths, gedi_grid, buffer = 12.5, fun = 'max', quiet
230231
eth[is.nan(eth)] = NA
231232
}
232233
}
233-
if (!is.null(sn)){
234+
if (any(!is.null(sn), !is.null(bb))){
234235
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+
}
237244
}
238245
# 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)
240247
gedi_grid = dplyr::select(gedi_grid, dplyr::everything(), dplyr::starts_with("geom"))
241248
attr(gedi_grid, "grid_type") = gtype
242249
if (!quiet) message("Complete!")

0 commit comments

Comments
 (0)