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
- Host: GitHub
- URL: https://github.com/worldbank/blackmarblepy
- Owner: worldbank
- License: mit
- Created: 2023-10-26T09:17:26.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2026-07-06T18:27:32.000Z (about 1 month ago)
- Last Synced: 2026-08-03T14:49:59.592Z (7 days ago)
- Topics: blackmarble, datapartnership, nasa, nasa-data, nasa-earth-data, nightlights, nighttime-lights, raster-data, viirs, worldbank, zonal-statistics
- Language: Jupyter Notebook
- Homepage: https://worldbank.github.io/blackmarblepy/
- Size: 54.7 MB
- Stars: 64
- Watchers: 13
- Forks: 19
- Open Issues: 12
- Releases: 15
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
README.md
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 (via exactextract).
- 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. If not familiar with environment variables, you may pass the token directly as thetokenargument.
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
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 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
- Name: World Bank Group
- Login: worldbank
- Email: github@worldbank.org
- Kind: organization
- Description: World Bank Repository for Data Products and tools. Content does not necessarily represent official World Bank Group positions, policies, recommendations, etc.
- Website:
- Location:
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/6454132?v=4
- Repositories: 182
- Last ynced at: 2023-08-06T00:01:50.096Z
- Profile URL: https://github.com/worldbank
GitHub Events
Total
- Release event: 5
- Delete event: 9
- Member event: 1
- Pull request event: 32
- Fork event: 8
- Issues event: 30
- Watch event: 14
- Issue comment event: 33
- Push event: 50
- Pull request review comment event: 2
- Pull request review event: 2
- Create event: 20
Last Year
- Delete event: 4
- Pull request event: 15
- Issues event: 15
- Watch event: 2
- Issue comment event: 7
- Push event: 22
- Create event: 6
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 | 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:
- garrett.co.uk: 1
- email.wm.edu: 1
- worldbank.org: 1
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
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
- Total packages: 2
-
Total downloads:
- pypi: 1,253 last-month
- Total dependent packages: 0 (may contain duplicates)
- Total dependent repositories: 0 (may contain duplicates)
- Total versions: 23
- Total maintainers: 1
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
- 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
- actions/checkout v4 composite
- actions/setup-python v5 composite
- actions/checkout v4 composite
- actions/deploy-pages v4 composite
- actions/setup-python v5 composite
- actions/upload-pages-artifact v3 composite
- 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