sen2nbar

Nadir BRDF Adjusted Reflectance (NBAR) for Sentinel-2 in Python

https://github.com/esds-leipzig/sen2nbar

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 20 DOI reference(s) in README
  • Academic publication links
    Links to: arxiv.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (8.8%) to scientific vocabulary

Keywords

brdf copernicus earth-observation esa geographic-information-systems geospatial python remote-sensing satellite-imagery sentinel sentinel-2 stac xarray
Last synced: 6 months ago · JSON representation ·

Repository

Nadir BRDF Adjusted Reflectance (NBAR) for Sentinel-2 in Python

Basic Info
Statistics
  • Stars: 58
  • Watchers: 3
  • Forks: 5
  • Open Issues: 1
  • Releases: 7
Topics
brdf copernicus earth-observation esa geographic-information-systems geospatial python remote-sensing satellite-imagery sentinel sentinel-2 stac xarray
Created about 3 years ago · Last pushed over 1 year ago
Metadata Files
Readme Funding License Citation

README.md

cubo

Nadir BRDF Adjusted Reflectance (NBAR) for Sentinel-2 in Python

PyPI conda-forge Documentation Status arXiv Tests License GitHub Sponsors Buy me a coffee Ko-fi Twitter Black isort


GitHub: https://github.com/ESDS-Leipzig/sen2nbar

Documentation: https://sen2nbar.readthedocs.io/

PyPI: https://pypi.org/project/sen2nbar/

Conda-forge: https://anaconda.org/conda-forge/sen2nbar

Tutorials: https://sen2nbar.readthedocs.io/en/latest/tutorials.html

Paper: https://doi.org/10.5194/isprs-archives-XLVIII-4-W12-2024-105-2024


[!IMPORTANT]
Our sen2nbar paper is out! Check it here: Montero, D., Mahecha, M.D., Aybar, C., Mosig, C., & Wieneke, S. (2024). Facilitating Advanced Sentinel-2 Analysis Through a Simplified Computation of Nadir BRDF Adjusted Reflectance.

Overview

First, a super small glossary:

  • BRDF: Bidirectional Reflectance Distribution Function.
  • DN: Digital Number.
  • NBAR: Nadir BRDF Adjusted Reflectance.
  • SR: Surface Reflectance.
  • STAC: SpatioTemporal Assets Catalogs.

Second, the amazing bibliography by David P. Roy et al., used to create this package:

Third, the super useful bibliography by Lucht et al.,:

Given this, and in a few words, sen2nbar converts the Sentinel-2 SR (i.e., L2A) to Sentinel-2 NBAR via the c-factor method.

SAFE

You can use sen2nbar to convert complete images via SAFE:

```python from sen2nbar.nbar import nbar_SAFE

Converted images are saved inside the SAFE path

nbarSAFE("S2AMSIL2A20230223T075931N0509R035T35HLC_20230223T120656.SAFE") ```

Note

Note that sen2nbar automatically shifts the DN of images with a processing baseline >= 04.00. This includes data cubes obtained via stackstac or cubo.

stackstac

Or, if you are using STAC and retrieving images via stackstac:

```python import pystacclient import stackstac import planetarycomputer as pc from sen2nbar.nbar import nbar_stackstac

Important infor for later

endpoint = "https://planetarycomputer.microsoft.com/api/stac/v1" collection = "sentinel-2-l2a" bounds = (-148.565368, 60.800723, -147.443389, 61.183638)

Open the STAC

catalog = pystacclient.Client.open(endpoint, modifier=pc.signinplace)

Define your area

areaofinterest = { "type": "Polygon", "coordinates": [ [ [bounds[0], bounds[1]], [bounds[2], bounds[1]], [bounds[2], bounds[3]], [bounds[0], bounds[3]], [bounds[0], bounds[1]], ] ], }

Search the items

items = catalog.search( collections=[collection], intersects=areaofinterest, datetime="2019-06-01/2019-08-01", query={"eo:cloudcover": {"lt": 10}}, ).getall_items()

Retrieve all items as a xr.DataArray

stack = stackstac.stack( items, assets=["B05","B06","B07"], # Red Edge here, but you can use more! bounds_latlon=bounds, resolution=20 )

Convert it to NBAR!

da = nbar_stackstac( stack, stac=endpoint, collection=collection ) ```

Warning

These examples are done using Planetary Computer. If you are using data cubes retrieved via STAC (e.g., by using stackstac or cubo), we recommend you to use this provider. The provider Element84 is not supported at the moment.

cubo

And going deeper, if you are using cubo:

```python import cubo import xarray as xr from sen2nbar.nbar import nbar_cubo

Get your cube

da = cubo.create( lat=47.84815, lon=13.37949, collection="sentinel-2-l2a", bands=["B02","B03","B04"], # RGB here, but you can add more bands! startdate="2020-01-01", enddate="2021-01-01", edgesize=64, resolution=10, query={"eo:cloudcover": {"lt": 3}} )

Convert it to NBAR (This a xr.DataArray)

da = nbar_cubo(da) ```

Bands

sen2nbar converts the following bands (if available in the input data):

  • RGB Bands: 02, 03, 04.
  • Red Edge Bands: 05, 06, 07.
  • Broad NIR Band: 08.
  • SWIR Bands: 11, 12.

Installation

Install the latest version from PyPI:

pip install sen2nbar

Upgrade sen2nbar by running:

pip install -U sen2nbar

Install the latest version from conda-forge:

conda install -c conda-forge sen2nbar

Install the latest dev version from GitHub by running:

pip install git+https://github.com/davemlz/sen2nbar

Citation

If you use this work, please consider citing the following paper:

bibtex @article{montero2024sen2nbar, title = {Facilitating advanced Sentinel-2 analysis through a simplified computation of Nadir BRDF Adjusted Reflectance}, volume = {XLVIII-4/W12-2024}, ISSN = {2194-9034}, url = {http://dx.doi.org/10.5194/isprs-archives-XLVIII-4-W12-2024-105-2024}, DOI = {10.5194/isprs-archives-xlviii-4-w12-2024-105-2024}, journal = {The International Archives of the Photogrammetry, Remote Sensing and Spatial Information Sciences}, publisher = {Copernicus GmbH}, author = {Montero, David and Mahecha, Miguel D. and Aybar, César and Mosig, Clemens and Wieneke, Sebastian}, year = {2024}, month = jun, pages = {105–112} }

License

The project is licensed under the MIT license.

RSC4Earth

Owner

  • Name: ESDS-Leipzig
  • Login: ESDS-Leipzig
  • Kind: organization

Citation (CITATION.bib)

@article{montero2024sen2nbar,
  title = {Facilitating advanced Sentinel-2 analysis through a simplified computation of Nadir BRDF Adjusted Reflectance},
  volume = {XLVIII-4/W12-2024},
  ISSN = {2194-9034},
  url = {http://dx.doi.org/10.5194/isprs-archives-XLVIII-4-W12-2024-105-2024},
  DOI = {10.5194/isprs-archives-xlviii-4-w12-2024-105-2024},
  journal = {The International Archives of the Photogrammetry,  Remote Sensing and Spatial Information Sciences},
  publisher = {Copernicus GmbH},
  author = {Montero,  David and Mahecha,  Miguel D. and Aybar,  César and Mosig,  Clemens and Wieneke,  Sebastian},
  year = {2024},
  month = jun,
  pages = {105–112}
}

GitHub Events

Total
  • Issues event: 1
  • Watch event: 11
  • Issue comment event: 1
  • Fork event: 1
Last Year
  • Issues event: 1
  • Watch event: 11
  • Issue comment event: 1
  • Fork event: 1

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 75
  • Total Committers: 2
  • Avg Commits per committer: 37.5
  • Development Distribution Score (DDS): 0.027
Past Year
  • Commits: 5
  • Committers: 1
  • Avg Commits per committer: 5.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
davemlz d****t@g****m 73
aldotapia a****a@u****l 2
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 8
  • Total pull requests: 1
  • Average time to close issues: 17 days
  • Average time to close pull requests: about 18 hours
  • Total issue authors: 4
  • Total pull request authors: 1
  • Average comments per issue: 1.0
  • Average comments per pull request: 3.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 2
  • Pull requests: 0
  • Average time to close issues: 2 days
  • Average time to close pull requests: N/A
  • Issue authors: 2
  • Pull request authors: 0
  • Average comments per issue: 0.5
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • davemlz (4)
  • behzad-vahedi (2)
  • zhongguolishenglin (1)
  • cmosig (1)
Pull Request Authors
  • aldotapia (1)
Top Labels
Issue Labels
bug (5) duplicate (1)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 48 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 7
  • Total maintainers: 1
pypi.org: sen2nbar

Nadir BRDF Adjusted Reflectance (NBAR) for Sentinel-2 in Python

  • Versions: 7
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 48 Last month
Rankings
Dependent packages count: 7.0%
Stargazers count: 12.9%
Average: 18.9%
Downloads: 20.8%
Forks count: 23.3%
Dependent repos count: 30.5%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/tests.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
docs/docs-requirements.txt pypi
  • google-auth <3.0dev,>=2.14.1
  • ipython *
  • nbsphinx *
  • protobuf <3.18.0,>=3.12.0
  • pydata-sphinx-theme *
  • recommonmark *
  • sphinx >=1.4,
  • sphinx-copybutton *
  • sphinx-material *
  • sphinxcontrib-autoprogram *
requirements.txt pypi
  • dask *
  • numpy *
  • pandas *
  • rasterio *
  • requests *
  • xarray *
  • xmltodict *
setup.py pypi
  • cubo >=2023.7.2
  • pystac *
  • rasterio >=1.3.6
  • requests *
  • rioxarray >=0.13.4
  • scipy >=1.10.1
  • tqdm *
  • xmltodict *