lightson accepts any
sf polygon layer. The workflow below starts with the
bundled LGD state boundaries, then swaps in district-level GeoJSONs from
bharatviz.
library(sf)
#> Linking to GEOS 3.14.1, GDAL 3.12.2, PROJ 9.7.1; sf_use_s2() is TRUE
states <- get_india_admin("state")
nrow(states)
#> [1] 36
head(states[, c("state_name", "state_code")])
#> Simple feature collection with 6 features and 2 fields
#> Geometry type: GEOMETRY
#> Dimension: XY
#> Bounding box: xmin: 76.7052 ymin: 6.7528 xmax: 97.4129 ymax: 30.7941
#> Geodetic CRS: WGS 84
#> # A tibble: 6 × 3
#> state_name state_code geometry
#> <chr> <chr> <GEOMETRY [°]>
#> 1 A & N Islands 35 GEOMETRYCOLLECTION (POLYGON ((92.4043 10.7844, 9…
#> 2 Andhra Pradesh 37 MULTIPOLYGON (((80.7879 15.7605, 80.79048 15.764…
#> 3 Arunachal Pradesh 12 POLYGON ((96.1765 29.3452, 96.1799 29.3075, 96.2…
#> 4 Assam 18 MULTIPOLYGON (((91.5352 25.8839, 91.5304 25.8713…
#> 5 Bihar 10 POLYGON ((84.1093 27.5208, 84.1242 27.5108, 84.1…
#> 6 Chandigarh 04 POLYGON ((76.7723 30.7941, 76.7828 30.7892, 76.7…Download Bhuvan WMS rasters for a subset of years.
bhuvan_raster() derives the bounding box from the
geometry:
names(rasters)
#> [1] "2020" "2021" "2022"
rasters[["2022"]]
#> class : SpatRaster
#> size : 1024, 1024, 1 (nrow, ncol, nlyr)
#> resolution : 0.0285501, 0.02962432 (x, y)
#> extent : 68.1776, 97.4129, 6.7528, 37.0881 (xmin, xmax, ymin, ymax)
#> coord. ref. : lon/lat WGS 84 (EPSG:4326)
#> source(s) : memory
#> varname : filef7f64f64553
#> name : filef7f64f64553_1
#> min value : 10
#> max value : 245.9732Bhuvan WMS returns RGB visualisation tiles.
bhuvan_raster() converts these to single-band luminance via
lum = 0.2126*R + 0.7152*G + 0.0722*B (ITU-R BT.709). Values
are comparable across years for trend analysis but are not in
nW/cm^2/sr.
panel <- extract_panel(rasters, states, id_col = "state_name")
#> Warning in st_cast.GEOMETRYCOLLECTION(X[[i]], ...): only first part of
#> geometrycollection is retained
head(panel)
#> region_id year mean_radiance n_pixels
#> 1 A & N Islands 2020 72.73280 1
#> 37 A & N Islands 2021 NaN 0
#> 73 A & N Islands 2022 72.73280 1
#> 2 Andhra Pradesh 2020 89.00605 5425
#> 38 Andhra Pradesh 2021 89.06904 5619
#> 74 Andhra Pradesh 2022 85.62903 9063library(ggplot2)
sel <- c("Bihar", "Maharashtra", "Tamil Nadu", "Uttar Pradesh")
plot_ntl_trend(
panel[panel$region_id %in% sel, ],
region = sel,
caption = "Source: ISRO Bhuvan NTL portal"
)BHARATVIZ <- "https://bharatviz.org"
districts <- sf::read_sf(
file.path(BHARATVIZ, "India-bhuvan-districts.geojson")
)
nrow(districts)To use NASA VIIRS rasters, supply an Earthdata token: