BlackMarblePy

A Python package that provides a simple way to use nighttime lights data from NASA's Black Marble project that provides a product suite of daily, monthly and yearly global nighttime lights.
https://github.com/worldbank/blackmarblepy

Category: Sustainable Development
Sub Category: Environmental Satellites

Keywords

blackmarble datapartnership nasa nasa-data nasa-earth-data nightlights nighttime-lights raster-data viirs worldbank zonal-statistics

Keywords from Contributors

global-development data-for-good mobility ais-data data-good data-partnership ntl syria syria-economic-monitor economic-monitor

Last synced: 36 minutes ago
JSON representation

Repository metadata

Georeferenced Rasters and Statistics of Nightlights from NASA Black Marble

README.md

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.

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.


Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: about 12 hours ago

Total Commits: 161
Total Committers: 8
Avg Commits per committer: 20.125
Development Distribution Score (DDS): 0.584

Commits in past year: 13
Committers in past year: 3
Avg Commits per committer in past year: 4.333
Development Distribution Score (DDS) in past year: 0.231

Name Email Commits
Rob Marty r****3@g****m 67
Gabriel Stefanini Vicente g****e@w****g 63
Rob Marty r****y@e****u 14
pre-commit-ci[bot] 6****] 10
dependabot[bot] 4****] 2
SahitiSarva 5****a 2
Pete Gadomski p****i@g****m 2
Russ Garrett r****s@g****k 1

Committer domains:


Issue and Pull Request metadata

Last synced: about 19 hours ago

Total issues: 71
Total pull requests: 116
Average time to close issues: 3 months
Average time to close pull requests: 16 days
Total issue authors: 29
Total pull request authors: 9
Average comments per issue: 1.1
Average comments per pull request: 0.34
Merged pull request: 83
Bot issues: 0
Bot pull requests: 44

Past year issues: 9
Past year pull requests: 12
Past year average time to close issues: 4 months
Past year average time to close pull requests: 1 day
Past year issue authors: 7
Past year pull request authors: 6
Past year average comments per issue: 1.89
Past year average comments per pull request: 0.5
Past year merged pull request: 2
Past year bot issues: 0
Past year bot pull requests: 7

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/worldbank/blackmarblepy

Top Issue Authors

  • g4brielvs (30)
  • ramarty (8)
  • Holly-Transport (5)
  • gadomski (2)
  • tonygem2022 (2)
  • TokyAxel (1)
  • lnicoletti (1)
  • yukinko-iwasaki (1)
  • aizadyar23 (1)
  • kbjarkefur (1)
  • bluginbuhl (1)
  • timginting (1)
  • emilytheok (1)
  • elbeejay (1)
  • ashbate (1)

Top Pull Request Authors

  • g4brielvs (58)
  • pre-commit-ci[bot] (27)
  • dependabot[bot] (17)
  • ramarty (4)
  • gadomski (3)
  • russss (2)
  • koichisato-dev (2)
  • SahitiSarva (2)
  • charles-openclaw (1)

Top Issue Labels

  • bug (38)
  • help wanted (22)
  • enhancement (15)
  • question (9)
  • documentation (4)
  • good first issue (1)

Top Pull Request Labels

  • enhancement (25)
  • documentation (19)
  • dependencies (17)
  • bug (5)
  • python (5)
  • github_actions (2)
  • wontfix (2)

Package metadata

proxy.golang.org: github.com/worldbank/blackmarblepy

  • Homepage:
  • Documentation: https://pkg.go.dev/github.com/worldbank/blackmarblepy#section-documentation
  • Licenses: mit
  • Latest release: v2025.11.2+incompatible (published 9 months ago)
  • Last Synced: 2026-08-10T08:37:29.838Z (about 14 hours ago)
  • Versions: 8
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Rankings:
    • Dependent packages count: 5.395%
    • Average: 5.576%
    • Dependent repos count: 5.758%
pypi.org: blackmarblepy

Georeferenced Rasters of Nighttime Lights from NASA Black Marble data

  • Homepage: https://worldbank.github.io/blackmarblepy
  • Documentation: https://blackmarblepy.readthedocs.io/
  • Licenses: MIT License Copyright (c) 2026 World Bank Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  • Latest release: 2026.6.1 (published about 2 months ago)
  • Last Synced: 2026-08-10T08:37:28.155Z (about 14 hours ago)
  • Versions: 15
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 1,253 Last month
  • Rankings:
    • Dependent packages count: 10.082%
    • Average: 38.691%
    • Dependent repos count: 67.3%
  • Maintainers (1)

Dependencies

.github/workflows/release.yml actions
  • actions/checkout v4 composite
  • actions/download-artifact v4 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v4 composite
  • pypa/gh-action-pypi-publish release/v1 composite
.github/workflows/tests.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
.github/workflows/gh-pages.yml actions
  • actions/checkout v4 composite
  • actions/deploy-pages v4 composite
  • actions/setup-python v5 composite
  • actions/upload-pages-artifact v3 composite
pyproject.toml pypi
  • aiohttp >=3.12.7
  • geopandas <2
  • h5py >=3.13.0
  • httpx >=0.28.1
  • humanize >=4.12.3
  • ipywidgets <9
  • nest-asyncio <2
  • numpy >=1.21.0,<3
  • pandas >=2,<3
  • pqdm >=0.2.0
  • pydantic >2,<3
  • rasterio >=1,<2
  • rasterstats >=0.20.0
  • rioxarray >=0.15.1,<0.18.0
  • tenacity >=9.1.2
  • tqdm >=4.67.1
  • xarray >=0.7.0

Score: 13.544268603159033