Recent Releases of sen2nbar

sen2nbar - 2024.6.0

sen2nbar v2024.6.0 :artificial_satellite:

  • Pinned: Pinned: cubo>=2024.6.0. This avoids numpy>=2.0.0 since stackstac breaks.

- Python
Published by davemlz over 1 year ago

sen2nbar - 2023.8.1

sen2nbar v2023.8.1 :artificial_satellite:

  • Fixed the occurrence of infinite values.

- Python
Published by davemlz over 2 years ago

sen2nbar - 2023.8.0

sen2nbar v2023.8.0 :artificial_satellite:

  • Fixed concatenation error when c-factor had been reprojected.

- Python
Published by davemlz over 2 years ago

sen2nbar - 2023.7.2

sen2nbar v2023.7.2 :artificial_satellite:

  • Raise ValueError events when not all bands include angle values.
  • Exclude timesteps in nbar_stac when not all bands include angle values.

- Python
Published by davemlz over 2 years ago

sen2nbar - 2023.7.1

sen2nbar v2023.7.1 :artificial_satellite:

  • Catch RuntimeWarning events when doing np.nanmean of detector angles.
  • Added description to tqdm progress bar and set leave=False.
  • Replaced get_all_items() by item_collection().

- Python
Published by davemlz over 2 years ago

sen2nbar - 2023.7.0

sen2nbar v2023.7.0 :artificial_satellite:

  • Fixed path separators by os (https://github.com/ESDS-Leipzig/sen2nbar/issues/4).
  • Pinned latest versions: :code:cubo>=2023.7.0.
  • Fixed the required datatype of the EPSG code for stackstac (https://github.com/ESDS-Leipzig/sen2nbar/issues/5)

- Python
Published by davemlz over 2 years ago

sen2nbar - 2023.3.0

sen2nbar v2023.3.0 :artificial_satellite: (First Release!)

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

NBAR

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) ```

- Python
Published by davemlz almost 3 years ago