Black Marble NTL Toolkit
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.
Metadata
Release files for blackmarble-ntl-toolkit 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| blackmarble_ntl_toolkit-0.1.2.tar.gz | 2.9 MB | Without provenance | Details for blackmarble_ntl_toolkit-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| blackmarble_ntl_toolkit-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for blackmarble_ntl_toolkit-0.1.2-py3-none-any.whl |
Total release size: 3.0 MB
Release files / blackmarble_ntl_toolkit-0.1.2.tar.gz
| Download URL | blackmarble_ntl_toolkit-0.1.2.tar.gz |
|---|---|
| Size | 2.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7db9a75284b30580cae6d942c8b1e6defb56e6850f359561f8fb1ff632ccd316
|
|
BLAKE2b-256 checksum How to use checksums |
b4c4d83db96b8cfb1e739ace23bc1542bae8d554ed302db36e963b4de8eed1c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}
|
Release files / blackmarble_ntl_toolkit-0.1.2-py3-none-any.whl
| Download URL | blackmarble_ntl_toolkit-0.1.2-py3-none-any.whl |
|---|---|
| Size | 31.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0a68e4b24539d780ec8e5ea8f415f50b2a240acf5505c630e228e86c65457d6a
|
|
BLAKE2b-256 checksum How to use checksums |
cc7564cb6ea9bf6aab634712789d67315b3a08607f5dd8345640c797ce303848
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}
|
Security for blackmarble-ntl-toolkit 0.1.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.