Page 1 of 1

NASA's Black Marble monthly data: Reprojection isn't accurate

Posted: Sat Sep 09, 2023 11:07 am America/New_York
by nikos_geography
I downloaded NASA's Black Marble monthly nighttime light NTL data, VNP46A3. Ι am trying to set the projection to EPSG:4326 but the resulting product (All_Angles_Snow_Free) seems to go go way off. For example, I wanted to download NTL data for the city of Mumbai, India. After reprojecting the NTL (product 5 (All_Angles_Snow_Free) from the .h5) the result is shown in the attachement.

At the bottom if the image is a shp of Mumbai and the red circle in the top indicates where Mumbai is in the NTL image. Clearly something's not right.

I downloaded the image from here (LAADS-DAAC, Level-1 and Atmosphere Archive & Distribution System Distributed Active Archive Center). The code I used to extract the NTL radiance image is:

library(terra)

wd <- "path/"

r <- rast(paste0(wd, "VNP46A3.A2018091.h25v07.001.2021125122857.h5"))
crs(r) <- "epsg:4326"

2400*(15/(60*60))

h = 25
v = 7

ext(r) = c(-180+h*10,-180+(h+1)*10, (v-2)*10,(v-1)*10)

ntl <- r[[5]]
writeRaster(ntl, paste0(wd, "ntl.tif"), overwrite = TRUE)

What's wrong with the code? From here (https://drive.google.com/drive/folders/1V115zpdU2-5fXssI6iWv_F6aNu4E5qA7?usp=drive_link) you can download the .h5 image if you don't want to use NASA's website. I am using R 4.3.1 and RStudio 2023.06.2+561.

Re: NASA's Black Marble monthly data: Reprojection isn't accurate

Posted: Mon Sep 11, 2023 12:42 pm America/New_York
by LAADSx_UserServices_M
Hi Nikolaos,
Yes, it appears that the issue lies in how you're calculating the spatial extent. This is how you calculate the bounding box using the horizontal (h) and vertical(v) time number –

WestBoundCoord = (10*HorizontalTileNumber) - 180
NorthBoundCoord = 90-(10*VerticalTileNumber)

EastBoundCoord = WestBoundCoord + 10
SouthBoundCoord = NorthBoundCoord - 10

I've noticed that you're using the R program to extract the VNP46A3 layer. We actually have a Python script that accomplishes the same task. Here is a script for you reference –
https://blackmarble.gsfc.nasa.gov/tools/OpenHDF5.py

Re: NASA's Black Marble monthly data: Reprojection isn't accurate

Posted: Mon Jul 01, 2024 4:46 am America/New_York
by nikos_geography
Thank you for the reply and I apologize for my late response. I found a very handy package in R that takes care of everything (reprojection, clipping to the desired extent, download daily, monthly and annual products etc). It called blackmarbler (https://github.com/worldbank/blackmarbler).

Re: NASA's Black Marble monthly data: Reprojection isn't accurate

Posted: Tue Jul 02, 2024 7:57 am America/New_York
by LAADSx_UserServices_M
Thanks very much for the information. Yes, we have this tool available from our black marble tools website at:
https://blackmarble.gsfc.nasa.gov/Tools.html