Skip to main content

BlackMarblePy

Project Status: Active – The project has reached a stable, usable state and is being actively developed. PyPI version License: MIT Python Version DOI Downloads Open In Colab GitHub Repo stars

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 (via exactextract).
      • Plot time series of nighttime lights data.

Documentation

docs tests pre-commit.ci status

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
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:

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="2026-04-22",
)

Alternatively, you can use the procedural procedural interface to retrieve NASA Black Marble data. All data are sourced from the NASA Black Marble project, specifically from the VNP46 product suite (e.g. VNP46A4). For more detailed information and examples, please refer to the examples.

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 Vicente ORCID logo
Robert Marty ORCID logo

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

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 project is licensed under the MIT License together with the World Bank IGO Rider. The Rider is purely procedural: it reserves all privileges and immunities enjoyed by the World Bank, without adding restrictions to the MIT permissions. Please review both files before using, distributing or contributing.

Metadata

Release files for blackmarblepy 2026.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for blackmarblepy 2026.6.1
File Size Uploaded
blackmarblepy-2026.6.1.tar.gz 10.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for blackmarblepy 2026.6.1
File Interpreter ABI Platform
blackmarblepy-2026.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.3 MB

Release files / blackmarblepy-2026.6.1.tar.gz

Download URL blackmarblepy-2026.6.1.tar.gz
Size 10.3 MB
Tags Source
SHA-256 checksum
How to use checksums
899cf2dc5cae96089a927beafc50b0e3269477c2dd0fe115fec2361a153b2058
BLAKE2b-256 checksum
How to use checksums
9015647aa711de05592950933376678483a2a4e4a797c3ce7182f4d793c413cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 16, 2026.

Transparency log

Release files / blackmarblepy-2026.6.1-py3-none-any.whl

Download URL blackmarblepy-2026.6.1-py3-none-any.whl
Size 32.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
760590d32794f3d3a372f86737a9d62f692253c397353439b0d36c6a9fadd74b
BLAKE2b-256 checksum
How to use checksums
6355596718096ea6a6189893d4cd850be74b59bb17b4b4cc27f60a30c2e69305
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 16, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page