Skip to main content

A Python toolkit for retrieving and preprocessing NASA's Black Marble Nighttime Light (NTL) data using Google Earth Engine, xarray, and Dask.

Project description

Black Marble NTL Toolkit

Documentation Python 3.13+ License

Black Marble NTL Toolkit is a Python package designed to streamline the retrieval, cleaning, aggregation, and visualization of NASA's Nighttime Light (NTL) data.

Deploying NTL data for conflict monitoring or socioeconomic research demands a combination of deep domain expertise and advanced technical proficiency to retrieve, process, and analyze large-scale datasets. Consequently, effective research relies on close collaboration between conflict researchers, machine learning specialists, and data engineers. To lower these technical barriers and facilitate independent experimentation, the codebase contains helper functions designed to streamline the retrieval, cleaning, and visualization of NTL data.

📚 Documentation

Full documentation, tutorials, and API reference can be found here:
🔗 https://jankokla.github.io/blackmarble-ntl-toolkit/


✨ Main Functionality

1. Earth Engine Authentication & Data Retrieval

Before retrieving data, you must authenticate and initialize the Google Earth Engine Python API. Once initialized, you can seamlessly pull down daily and annual NASA Black Marble products.

from blackmarble_toolkit.utils import initialize_ee
from blackmarble_toolkit.retrieval import BlackMarbleRetriever

initialize_ee(project_name="your-gee-project-id")

retriever = BlackMarbleRetriever()

raw_ds = retriever.get_data(
    product="VNP46A2",
    start_date="2022-01-01", 
    end_date="2022-12-31",
    region=geometry
)

2. Preprocessing Pipeline

Create a robust, memory-efficient pipeline leveraging Dask and Xarray to filter out clouds, snow, and background noise, and correct geometric or angular distortions.

from blackmarble_toolkit.pipeline import NTLPipeline
from blackmarble_toolkit.methods import filters, angular, geometric, imputation

steps = [
    filters.CloudSnowFilter(),
    angular.QuadraticVZACorrection(),
    geometric.AveragePooling2D(filter_size=(3, 3)),
    imputation.LinearInterpolationGapFilling()
]

pipeline = NTLPipeline(steps)
processed_ds = pipeline.run(raw_ds, cache_intermediates=True)

3. Spatial Aggregation

Map your pixel-level NTL radiance to custom geometries (like administrative regions) for time-series analysis.

import geopandas as gpd

regions = gpd.read_file("regions.geojson")
regions = regions.reset_index(names="region_id")

aggregated_results = pipeline.aggregate(
    gdf=regions,
    geo_id_col="region_id"
)

4. Exporting to CSV

If you prefer doing downstream analysis and plotting in pandas or R, you can easily export the aggregated results to a CSV file.

df = pipeline.to_csv("ntl_aggregated_results.csv")

🛠️ Installation

You can install the toolkit directly via PyPI:

pip install blackmarble-ntl-toolkit

For more details on setting up your environment and configuring Earth Engine, please consult the Installation Guide.

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

blackmarble_ntl_toolkit-0.1.0.tar.gz (2.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

blackmarble_ntl_toolkit-0.1.0-py3-none-any.whl (30.1 kB view details)

Uploaded Python 3

File details

Details for the file blackmarble_ntl_toolkit-0.1.0.tar.gz.

File metadata

  • Download URL: blackmarble_ntl_toolkit-0.1.0.tar.gz
  • Upload date:
  • Size: 2.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for blackmarble_ntl_toolkit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4a4d4b91b51494d3877202262bbdaff85dde64b5c39b51e6273f0ee5e533a6bf
MD5 44a1d87e13651deff45a1d2a6d33117e
BLAKE2b-256 0b6e73f228291c8ca08c9c80fe643581644bc71f5f3e635c5f2316200a7acba9

See more details on using hashes here.

File details

Details for the file blackmarble_ntl_toolkit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: blackmarble_ntl_toolkit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 30.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for blackmarble_ntl_toolkit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f8e0d3e14b8a19366e994395a8f688fe22702d7624850b4e81a3ca3b5ad4e952
MD5 8abf62c6a0cb35cbece7480c8b8ce093
BLAKE2b-256 4e8ecc3543393b235ced0c3570b617bef476124bde8c23fa54f4f2496a7f0c6c

See more details on using hashes here.

Supported by

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