Skip to content

Commit

Permalink
Refactoring (#20)
Browse files Browse the repository at this point in the history
* Remove examples

* Cleaning up

* Add download progress bar

* Remove unnecessary functions

* Add Black Marble tiles

* Remove CLI

* Add package data

* Add logging

* Update examples

* Update docs

* Add BlackMarbleDownloader

* Update table of contents
  • Loading branch information
g4brielvs committed Dec 1, 2023
1 parent f54cf19 commit 6731e21
Show file tree
Hide file tree
Showing 17 changed files with 23,260 additions and 2,382 deletions.
48 changes: 2 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,59 +15,15 @@

## Installation

You can install BlackMarblePy using pip:
**BlackMarblePy** is available on [PyPI](https://pypi.org); you can install it using `pip`:

```shell
pip install blackmarblepy
```

## Usage

Before downloading and extracting Black Marble data, we first load libraries, define the NASA bearer token, and define a region of interest.

```python
## Libraries
from blackmarble.bm_raster import bm_raster
from blackmarble.bm_extract import bm_extract

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from gadm import GADMDownloader
import seaborn as sns

## Bear token
bearer == "BEARER TOKEN HERE"

## Get Region of Interest - Ghana
downloader = GADMDownloader(version="4.0")

country_name = "Ghana"
ghana_adm1 = downloader.get_shape_data_by_country_name(country_name=country_name,
ad_level=1)
```

### Raster of Nighttime Lights <a name="quickstart-raster"></a>

The below example shows making an annual raster of nighttime lights for Ghana.

```python
## Raster of nighttime lights
r = bm_raster(roi_sf = ghana_adm1,
product_id = "VNP46A4",
date = 2022,
bearer = bearer)

## Map raster
r_np = r.read(1)
r_np = np.log(r_np+1)

plt.imshow(r_np, cmap='hot')
plt.tight_layout()
plt.axis("off")
```

For more detailed documentation and examples, please refer to the [documentation](https://worldbank.github.io/blackmarblepy/quickstart.html).
Before downloading and extracting Black Marble data, define the NASA bearer token, and define a region of interest. For more detailed documentation and examples, please refer to the [documentation](https://worldbank.github.io/blackmarblepy).

## Contributing

Expand Down
1 change: 1 addition & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ sphinx:
html_last_updated_fmt: "%b %d, %Y"
apidoc_module_dir: "../src"
extra_extensions:
- "sphinx.ext.napoleon"
- "sphinxcontrib.apidoc"
3 changes: 1 addition & 2 deletions docs/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ parts:
- file: CONTRIBUTING
- caption: Examples
chapters:
- file: quickstart
- file: examples/blackmarbley_example.ipynb
- file: examples/blackmarblepy.ipynb
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"sphinx_book_theme",
"sphinxcontrib.bibtex",
"sphinx_jupyterbook_latex",
"sphinx.ext.napoleon",
"sphinxcontrib.apidoc",
]
external_toc_exclude_missing = True
Expand Down
Loading

0 comments on commit 6731e21

Please sign in to comment.