Georeferenced Rasters of Nighttime Lights from NASA Black Marble data
Project description
BlackMarblePy
BlackMarblePy is a Python package that provides a simple way to use nighttime lights data from NASA's Black Marble project. Black Marble is a NASA Earth Science Data Systems (ESDS) project that provides a product suite of daily, monthly and yearly global nighttime lights. This package automates the process of downloading all relevant tiles from the NASA LAADS DAAC to cover a region of interest, converting the raw files (in HDF5 format) to georeferenced rasters, and mosaicking rasters together when needed.
Features
- Download daily, monthly, and yearly nighttime lights data for user-specified region of interest and time.
- Parallel downloading for faster data retrieval and automatic retry mechanism for handling network errors.
- Access NASA Black Marble as a xarray.Dataset
- Integrated data visualization with customization options
- Choose between various plot types, including bar charts, line graphs, and heatmaps.
- Customize plot appearance with color palettes, axes labels, titles, and legends.
- Save visualizations as high-resolution images for presentations or reports.
- Perform time series analysis on nighttime lights data.
- Calculate zonal statistics like mean and sum.
- Plot time series of nighttime lights data.
- Integrated data visualization with customization options
Documentation
The BlackMarblePy library allows you to interact with and manipulate data from NASA's Black Marble, which provides global nighttime lights data. Below is a guide on how to use the key functionalities of the library.
Installation
BlackMarblePy is available on PyPI. To install, it is recommended to use virtual environment and package manager. While pip is the usual choice, we recommend using uv.
Using pip
pip install blackmarblepy
Using uv (recommended)
uv add blackmarblepy
Usage
BlackMarblePy requires a NASA Earthdata token for authenticated access to the NASA LAADS archive. To obtain a token, log in or register at Earthdata Login and generate a personal access token from your Earthdata profile.
Before downloading or extracting NASA Black Marble data, ensure the following:
- You have defined a region of interest
gdfas ageopandas.GeoDataFrame, which represents the area over which data will be queried and downloaded. - You have a valid and not expired
tokenset (retrieved from your Earthdata profile). For convenience and security, we recommend setting your token as anBLACKMARBLE_TOKENenvironment variable.
import geopandas as gpd
from blackmarble import BlackMarble, Product
# ------------------------------------------------------------------------------
# 1. Define your region of interest
# ------------------------------------------------------------------------------
# In this example ,we load a region from a GeoJSON.
gdf = gpd.read_file("path/to/your/shapefile.geojson")
# ------------------------------------------------------------------------------
# 2. Set up the BlackMarble client
# ------------------------------------------------------------------------------
# If the environment variable `BLACKMARBLE_TOKEN` is set, it will be used automatically.
# You can also pass your token directly, but using the environment variable is recommended.
bm = BlackMarble(token="YOUR_BLACKMARBLE_TOKEN")
# ------------------------------------------------------------------------------
# 3. Download VNP46 data from NASA Earthdata
# ------------------------------------------------------------------------------
# In this example, we request the VNP46A2 product for a specific date.
# The data is returned as an xarray.Dataset.
raster_earth_day = bm.raster(
gdf,
product_id=Product.VNP46A2,
date_range="2025-04-22",
)
Alternatively, you may use the procedural interface to retrieve NASA Black Marble data. All data are sourced from the NASA LAADS archive, specifically from the VNP46 product suite (e.g. VNP46A4). For more detailed information and examples, please refer to the examples.
Specifying NASA Black Marble Collection Version
By default, BlackMarblePy uses Collection 2 ("5200"). To choose a different collection, pass the collection parameter when instantiating the BlackMarble object. For example:
from blackmarble import BlackMarble, Product
# For Collection 1 ("5000")
bm = BlackMarble(token="YOUR_TOKEN", collection="5000")
# For Collection 2 ("5200")
bm = BlackMarble(token="YOUR_TOKEN", collection="5200") # default
Full API Reference
For a full reference of all available functions and their parameters, please refer to the official documentation.
Contributing
We welcome contributions to improve this documentation. If you find errors, have suggestions, or want to add new content, please follow our contribution guidelines. Please see also .
Feedback and Issues
This project welcomes contributions of any kind! If you have any feedback, encounter issues, or want to suggest improvements, please open an issue.
Versioning
This project follows the YYYY.0M.MICRO CALVER scheme for versioning. If you have any questions or need more information about our versioning approach, feel free to ask.
Gabriel Stefanini VicenteRobert Marty
Citation
When using BlackMarblePy, your support is much appreciated! Please consider using the following citation or download bibliography.bib:
@misc{blackmarblepy,
title = {{BlackMarblePy: Georeferenced Rasters and Statistics of Nighttime Lights from NASA Black Marble}},
author = {Gabriel {Stefanini Vicente} and Robert Marty},
year = {2023},
howpublished = {\url{https://worldbank.github.io/blackmarblepy}},
doi = {10.5281/zenodo.10667907},
url = {https://worldbank.github.io/blackmarblepy},
}
{cite:empty}blackmarblepy
:filter: docname in docnames
:style: plain
Related Projects
Looking for an R implementation? Check out the blackmarbler package, which provides similar functionality for working with NASA Black Marble data in R.
License
This projects is licensed under the Mozilla Public License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file blackmarblepy-2025.11.2.tar.gz.
File metadata
- Download URL: blackmarblepy-2025.11.2.tar.gz
- Upload date:
- Size: 11.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
042d53c6f883b7d2077cf8a91c308aa1fc568e6f7e0c140d1649c001afe248c3
|
|
| MD5 |
ea5d993e9db8f74da1fa0be38e119bb8
|
|
| BLAKE2b-256 |
a89b5fa4d5902465d52998e3d94e5a76b73c0ff04e702d5cdc5ae3ef106645e4
|
Provenance
The following attestation bundles were made for blackmarblepy-2025.11.2.tar.gz:
Publisher:
release.yml on worldbank/blackmarblepy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
blackmarblepy-2025.11.2.tar.gz -
Subject digest:
042d53c6f883b7d2077cf8a91c308aa1fc568e6f7e0c140d1649c001afe248c3 - Sigstore transparency entry: 700433541
- Sigstore integration time:
-
Permalink:
worldbank/blackmarblepy@1bdad1af8e218feb7402146bdc2325ac3a224bfd -
Branch / Tag:
refs/tags/v2025.11.2 - Owner: https://github.com/worldbank
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1bdad1af8e218feb7402146bdc2325ac3a224bfd -
Trigger Event:
release
-
Statement type:
File details
Details for the file blackmarblepy-2025.11.2-py3-none-any.whl.
File metadata
- Download URL: blackmarblepy-2025.11.2-py3-none-any.whl
- Upload date:
- Size: 41.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7771e5e4248d195ff6ad034632c3f30ef617c7d343b7e344217f1178f0e10a6f
|
|
| MD5 |
b8568024271e5f72e1366f4dfa810553
|
|
| BLAKE2b-256 |
6c546d90acab151395844b2bbeaf089dac4c421e1ccc6144aef1d1cc1b36f0b4
|
Provenance
The following attestation bundles were made for blackmarblepy-2025.11.2-py3-none-any.whl:
Publisher:
release.yml on worldbank/blackmarblepy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
blackmarblepy-2025.11.2-py3-none-any.whl -
Subject digest:
7771e5e4248d195ff6ad034632c3f30ef617c7d343b7e344217f1178f0e10a6f - Sigstore transparency entry: 700433548
- Sigstore integration time:
-
Permalink:
worldbank/blackmarblepy@1bdad1af8e218feb7402146bdc2325ac3a224bfd -
Branch / Tag:
refs/tags/v2025.11.2 - Owner: https://github.com/worldbank
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1bdad1af8e218feb7402146bdc2325ac3a224bfd -
Trigger Event:
release
-
Statement type: