File tree Expand file tree Collapse file tree 3 files changed +47
-1
lines changed Expand file tree Collapse file tree 3 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ License: MIT + file LICENSE
9
9
Encoding: UTF-8
10
10
Roxygen: list(markdown = TRUE)
11
11
RoxygenNote: 7.2.1
12
- URL: https://github.com/worldbank/ blackmarbler
12
+ URL: https://worldbank. github.io/ blackmarbler/
13
13
BugReports: https://github.com/worldbank/blackmarbler/issues
14
14
biocViews:
15
15
Imports:
Original file line number Diff line number Diff line change 7
7
8
8
usethis :: use_pkgdown()
9
9
pkgdown :: build_site()
10
+ pkgdown :: build_site_github_pages()
10
11
usethis :: use_pkgdown_github_pages()
11
12
12
13
usethis :: use_pkgdown()
Original file line number Diff line number Diff line change @@ -19,6 +19,51 @@ library(dplyr)
19
19
library(httr )
20
20
21
21
22
+
23
+ library(blackmarbler )
24
+ library(geodata )
25
+ library(sf )
26
+ library(ggplot2 )
27
+
28
+ # bearer <- "BEARER-TOKEN"
29
+
30
+ roi <- gadm(country = " GHA" ,
31
+ level = 0 ,
32
+ path = tempdir()) | >
33
+ st_as_sf()
34
+
35
+ r <- bm_extract(roi_sf = roi ,
36
+ product_id = " VNP46A4" ,
37
+ date = 2017 ,
38
+ bearer = bearer )
39
+
40
+ r <- r | > mask(roi_sf )
41
+
42
+ r_df <- rasterToPoints(r , spatial = TRUE ) | > as.data.frame()
43
+ names(r_df ) <- c(" value" , " x" , " y" )
44
+
45
+ # # Transform NTL
46
+ r_df $ value [r_df $ value < = 1 ] <- 0
47
+
48
+ r_df $ value_adj <- log(r_df $ value + 1 )
49
+
50
+ # #### Map
51
+ p <- ggplot() +
52
+ geom_raster(data = r_df ,
53
+ aes(x = x , y = y ,
54
+ fill = value_adj )) +
55
+ scale_fill_gradient2(low = " black" ,
56
+ mid = " yellow" ,
57
+ high = " red" ,
58
+ midpoint = 4.5 ) +
59
+ coord_quickmap() +
60
+ theme_void() +
61
+ theme(legend.position = " none" )
62
+
63
+
64
+
65
+
66
+
22
67
bearer <- read.csv(" ~/Desktop/bearer_bm.csv" ) %> %
23
68
pull(token )
24
69
You can’t perform that action at this time.
0 commit comments