Skip to main content

Georeferenced Rasters of Nighttime Lights from NASA Black Marble data

Project description

BlackMarblePy

License: MPL 2.0 PyPI version docs tests pre-commit.ci status downloads DOI 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 mosaicing 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.

Installation

BlackMarblePy is available on PyPI as blackmarblepy and can installed using pip:

From PyPI

pip install blackmarblepy

From Source

  1. Clone or download this repository to your local machine. Then, navigate to the root directory of the repository:

    git clone https://github.com/worldbank/blackmarblepy.git
    cd blackmarblepy
    
  2. Create a virtual environment (optional but recommended):

    python3 -m venv venv
    source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
    
  3. Install the package with dependencies:

    pip install .
    

    Install the package in editable mode with dependencies:

    pip install -e .
    

    The -e flag stands for "editable," meaning changes to the source code will immediately affect the installed package.

Building Documentation Locally

To build the documentation locally, after (1) and (2) above, please follow these steps:

  • Install the package with documentation dependencies:

      pip install -e .[docs]
    
  • Build the documentation:

      sphinx-build docs _build/html -b html
    

The generated documentation will be available in the _build/html directory. Open the index.html file in a web browser to view it.

Usage

Before downloading and extracting Black Marble data, define the NASA LAADS archive bearer token, and define a region of interest (i.e., gdf as a geopandas.GeoDataFrame).

from blackmarble.raster import bm_raster

# Retrieve VNP46A2 for date range into a Xarray Dataset
daily = bm_raster(
    gdf,
    product_id="VNP46A2",
    date_range=pd.date_range("2022-01-01", "2022-03-31", freq="D"),
    bearer=bearer,
)

For more detailed information and examples, please refer to the 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.

Feedback and Issues

If you have any feedback, encounter issues, or want to suggest improvements, please open an issue.

Versioning

CalVer

This project follows the CALVER (Calendar Versioning) scheme for versioning. If you have any questions or need more information about our versioning approach, feel free to ask.

Contributors

This project follows the all-contributors specification. Contributions of any kind are welcome!

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

License

This projects is licensed under the Mozilla Public License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blackmarblepy-2024.7.1.tar.gz (9.0 MB view details)

Uploaded Source

Built Distribution

blackmarblepy-2024.7.1-py3-none-any.whl (35.4 kB view details)

Uploaded Python 3

File details

Details for the file blackmarblepy-2024.7.1.tar.gz.

File metadata

  • Download URL: blackmarblepy-2024.7.1.tar.gz
  • Upload date:
  • Size: 9.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for blackmarblepy-2024.7.1.tar.gz
Algorithm Hash digest
SHA256 76562e8d61ac4945782a8f3c7939c52b88200addd5e204ec2f58830fb042bf1b
MD5 0d20bb36bcaff806cac98174881187a7
BLAKE2b-256 778264ee15b2e4ad5ad29fc89dc95db89d7574a20415730757372fadaaa6c9b2

See more details on using hashes here.

File details

Details for the file blackmarblepy-2024.7.1-py3-none-any.whl.

File metadata

File hashes

Hashes for blackmarblepy-2024.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f461a9703af91bda8fdeef3e012c5975549a41495088e39c7330b90db2c7a0b5
MD5 3183726d4e1fbce7d4d392c9ad730d05
BLAKE2b-256 d3857a1b8f02a470af733eb936d66fc617a81f5f98c739a8152a4aef40af2023

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page