You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: vignettes/assess-quality.Rmd
+12-13Lines changed: 12 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,7 @@ This page illustrates how to examine the quality of nighttime lights data.
45
45
46
46
We first load packages and obtain a polygon for a region of interest; for this example, we use Switzerland.
47
47
48
-
```{r}
48
+
```{r, results='hide'}
49
49
library(blackmarbler)
50
50
library(geodata)
51
51
library(sf)
@@ -56,6 +56,7 @@ library(exactextractr)
56
56
library(lubridate)
57
57
library(tidyr)
58
58
library(geodata)
59
+
library(knitr)
59
60
60
61
bearer <- "BEARER-TOKEN-HERE"
61
62
```
@@ -77,7 +78,7 @@ Below shows an example examining quality for daily data (`VNP46A2`).
77
78
78
79
We download data for January 1st, 2023. When the `variable` parameter is not specified, `bm_raster` creates a raster using the `Gap_Filled_DNB_BRDF-Corrected_NTL` variable for daily data.
By default, the `bm_extract` function computes these values:
139
140
140
-
```{r}
141
+
```{r, results='hide'}
141
142
ntl_df <- bm_extract(roi_sf = roi_sf,
142
143
product_id = "VNP46A2",
143
144
date = seq.Date(from = ymd("2023-01-01"),
@@ -184,7 +185,7 @@ For daily data, the quality values are:
184
185
185
186
We can map quality by using the `Mandatory_Quality_Flag` variable.
186
187
187
-
```{r}
188
+
```{r, results='hide'}
188
189
quality_r <- bm_raster(roi_sf = roi_sf,
189
190
product_id = "VNP46A2",
190
191
date = "2023-01-01",
@@ -229,7 +230,7 @@ ggplot() +
229
230
230
231
The `quality_flag_rm` parameter determines which pixels are set to `NA` based on the quality indicator. By default, only pixels with a value of `255` are filtered out. However, if we only want data for good quality pixels, we can adjust the `quality_flag_rm` parameter.
231
232
232
-
```{r}
233
+
```{r, results='hide'}
233
234
ntl_good_qual_r <- bm_raster(roi_sf = roi_sf,
234
235
product_id = "VNP46A2",
235
236
date = "2023-01-01",
@@ -273,7 +274,7 @@ ggplot() +
273
274
274
275
By default, the `bm_raster` function uses the `Gap_Filled_DNB_BRDF-Corrected_NTL` variable for daily data. Gap filling indicates that some poor quality pixels use data from a previous date; the `Latest_High_Quality_Retrieval` indicates the date the nighttime lights value came from.
#ntl_tmp_gap_df$value[ntl_tmp_gap_df$value == 255] <- NA
294
-
295
294
##### Map
296
295
ggplot() +
297
296
geom_raster(data = ntl_tmp_gap_df,
@@ -311,7 +310,7 @@ ggplot() +
311
310
312
311
Instead of using `Gap_Filled_DNB_BRDF-Corrected_NTL`, we could ignore gap filled observations---using the `DNB_BRDF-Corrected_NTL` variable. Here, we also remove poor quality pixels.
313
312
314
-
```{r}
313
+
```{r, results='hide'}
315
314
ntl_r <- bm_raster(roi_sf = roi_sf,
316
315
product_id = "VNP46A2",
317
316
date = "2023-01-01",
@@ -359,7 +358,7 @@ Below shows an example examining quality for monthly data (`VNP46A3`). The same
359
358
360
359
We download data for January 2023. When the `variable` parameter is not specified, `bm_raster` creates a raster using the `NearNadir_Composite_Snow_Free` variable for monthly and annual data---which is nighttime lights, removing effects from snow cover.
361
360
362
-
```{r}
361
+
```{r, results='hide'}
363
362
ntl_r <- bm_raster(roi_sf = roi_sf,
364
363
product_id = "VNP46A3",
365
364
date = "2023-01-01",
@@ -402,7 +401,7 @@ ggplot() +
402
401
403
402
Black Marble removes poor quality observations, such as pixels covered by clouds. To determine the number of observations used to generate nighttime light values for each pixel, we add `_Num` to the variable name.
404
403
405
-
```{r}
404
+
```{r, results='hide'}
406
405
cf_r <- bm_raster(roi_sf = roi_sf,
407
406
product_id = "VNP46A3",
408
407
date = "2023-01-01",
@@ -451,7 +450,7 @@ For monthly and annual data, the quality values are:
451
450
452
451
We can map quality by adding `_Quality` to the variable name.
453
452
454
-
```{r}
453
+
```{r, results='hide'}
455
454
quality_r <- bm_raster(roi_sf = roi_sf,
456
455
product_id = "VNP46A3",
457
456
date = "2023-01-01",
@@ -496,7 +495,7 @@ ggplot() +
496
495
497
496
The `quality_flag_rm` parameter determines which pixels are set to `NA` based on the quality indicator. By default, only pixels with a value of `255` are filtered out. However, if we also want to remove poor quality pixels, we can adjust the `quality_flag_rm` parameter.
0 commit comments