@@ -169,18 +169,20 @@ file_to_raster <- function(f,
169
169
str_replace_all(" _Std" , " " )
170
170
171
171
qf_name <- paste0(variable_short , " _Quality" )
172
+
172
173
if (qf_name %in% var_names ){
173
174
174
175
# qf <- h5_data$HDFEOS$GRIDS$VIIRS_Grid_DNB_2d$`Data Fields`[[paste0(variable, "_Quality")]]
175
- qf <- h5_data [[paste0(" HDFEOS/GRIDS/VIIRS_Grid_DNB_2d/Data Fields/" , variable , " _Quality " )]][,]
176
+ qf <- h5_data [[paste0(" HDFEOS/GRIDS/VIIRS_Grid_DNB_2d/Data Fields/" , qf_name )]][,]
176
177
177
178
for (val in quality_flag_rm ){ # out[qf %in% quality_flag_rm] doesn't work, so loop
178
179
out [qf == val ] <- NA
179
180
}
181
+
180
182
}
181
183
182
184
}
183
-
185
+
184
186
if (class(out [1 ,1 ])[1 ] != " numeric" ){
185
187
out <- matrix (as.numeric(out ), # Convert to numeric matrix
186
188
ncol = ncol(out ))
@@ -544,7 +546,7 @@ bm_extract <- function(roi_sf,
544
546
saveRDS(r_agg , out_path )
545
547
546
548
} else {
547
- cat (paste0(' "' , out_path , ' " already exists; skipping.\n ' ))
549
+ warning (paste0(' "' , out_path , ' " already exists; skipping.\n ' ))
548
550
}
549
551
550
552
r_out <- NULL # Saving as file, so output from function should be NULL
@@ -743,7 +745,7 @@ bm_raster <- function(roi_sf,
743
745
writeRaster(r , out_path )
744
746
745
747
} else {
746
- cat (paste0(' "' , out_path , ' " already exists; skipping.\n ' ))
748
+ warning (paste0(' "' , out_path , ' " already exists; skipping.\n ' ))
747
749
}
748
750
749
751
r_out <- NULL # Saving as tif file, so output from function should be NULL
@@ -863,10 +865,9 @@ bm_raster_i <- function(roi_sf,
863
865
# stop(st_intersects(bm_tiles_sf, roi_sf, sparse = F))
864
866
}
865
867
)
866
-
867
-
868
+
868
869
grid_use_sf <- bm_tiles_sf [inter > 0 ,]
869
-
870
+
870
871
# Make Raster ----------------------------------------------------------------
871
872
tile_ids_rx <- grid_use_sf $ TileID %> % paste(collapse = " |" )
872
873
bm_files_df <- bm_files_df [bm_files_df $ name %> % str_detect(tile_ids_rx ),]
0 commit comments