Skip to content

Commit 9ae57a8

Browse files
committed
fix hill mapping
1 parent 54ecbef commit 9ae57a8

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

R/biodivMapR_full_tiles.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ biodivMapR_full_tiles <- function(feature_dir, list_features, mask_dir = NULL,
4444
mosaic_output <- options$mosaic_output
4545
weightIRQ <- options$weightIRQ
4646

47+
# # adjust hill name if required
48+
# if ('hill' %in% alphametrics){
49+
#
50+
# }
51+
4752
# sample data if not already sampled
4853
samples <- biodivMapR_sample(feature_dir = feature_dir,
4954
list_features = list_features,

R/run_biodivMapR_plot.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ run_biodivMapR_plot <- function(id, feature_dir, mask_dir = NULL,
3535

3636
betanames <- paste0('beta_',id)
3737
alphanames <- paste0(alphametrics,'_',id)
38+
if ('hill' %in% alphametrics)
39+
alphanames[alphametrics=='hill'] <- paste0('hill_', Hill_order,'_',id)
3840
functionalname <- NULL
3941
if (!is.null(FDmetric))
4042
functionalname <- paste0(FDmetric,'_',id)

R/save_diversity_maps_mw.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ save_diversity_maps_mw <- function(input_raster_path,
4848
terra::values(template_rast[[1]]) <- ab_div_metrics[[idx]]$mean
4949
names(template_rast[[1]]) <- paste('mean', idx)
5050
# define output raster name
51-
if (is.null(output_raster_name[[idx2]]))
51+
if (is.null(output_raster_name[[idx]]))
5252
output_raster <- file.path(output_dir, paste0(idx2, '_mean'))
53-
if (!is.null(output_raster_name[[idx2]]))
53+
if (!is.null(output_raster_name[[idx]]))
5454
output_raster <- file.path(output_dir,
55-
paste0(output_raster_name[[idx2]], '_mean'))
55+
paste0(output_raster_name[[idx]], '_mean'))
5656

5757
if (filetype%in%c('GTiff', 'COG'))
5858
output_raster <- paste0(output_raster, '.tiff')
@@ -66,11 +66,11 @@ save_diversity_maps_mw <- function(input_raster_path,
6666
terra::values(template_rast[[1]]) <- ab_div_metrics[[idx]]$sd
6767
names(template_rast[[1]]) <- paste('sd', idx)
6868
# define output raster name
69-
if (is.null(output_raster_name[[idx2]]))
69+
if (is.null(output_raster_name[[idx]]))
7070
output_raster <- file.path(output_dir, paste0(idx2, '_sd'))
71-
if (!is.null(output_raster_name[[idx2]]))
71+
if (!is.null(output_raster_name[[idx]]))
7272
output_raster <- file.path(output_dir,
73-
paste0(output_raster_name[[idx2]], '_sd'))
73+
paste0(output_raster_name[[idx]], '_sd'))
7474
if (filetype%in%c('GTiff', 'COG'))
7575
output_raster <- paste0(output_raster, '.tiff')
7676
terra::writeRaster(x = template_rast, filename = output_raster,
@@ -111,7 +111,7 @@ save_diversity_maps_mw <- function(input_raster_path,
111111

112112
if (is.null(output_raster_name[['beta']]))
113113
output_raster <- file.path(output_dir, 'beta')
114-
if (!is.null(output_raster_name[[idx2]]))
114+
if (!is.null(output_raster_name[['beta']]))
115115
output_raster <- file.path(output_dir, output_raster_name[['beta']])
116116
if (filetype%in%c('GTiff', 'COG'))
117117
output_raster <- paste0(output_raster, '.tiff')

R/save_diversity_maps_tile.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ save_diversity_maps_tile <- function(input_raster_path,
3939

4040
for (idx in alphametrics) {
4141
idx2 <- idx
42-
if (idx == 'hill') idx2 <- paste0(idx, '_', Hill_order)
42+
if (idx == 'hill')
43+
idx2 <- paste0(idx, '_', Hill_order)
4344
# Mean value
4445
# produce a template
4546
template_rast <- terra::rast(input_raster_path[[1]])

0 commit comments

Comments
 (0)