Skip to main content

Python library for automatic land cover classification of Sentinel 2 satellite images

Project description

sen2classification

sen2classification is a Python library for automatic land cover classification of Sentinel 2 satellite images using machine learning.

Features

  • support for L1C and L2A Sentinel products
  • uses machine learning algorithms in combination with tresholding for classifying land covers
  • calculates spectral indices used for tresholding
  • Two classification methods are available:
    • ALCC (Automatic Land Cover Classification)
    • Gradient boosting
  • the end result is a classification raster which pixel values range from 0 to 5:
    • 0 = no data
    • 1 = water
    • 2 = low vegetation
    • 3 = high vegetation
    • 4 = soil
    • 5 = built up

Clouds are not classified, for optimal results use images with none or minimal cloud cover

ALCC

Automatic Land Cover Classification algorithm uses k-means clustering and tresholding for classifying land cover. The concept of ALCC was first introduced by Gašparović et al. (2019). They used it to classify Landsat-8 images at 30 m spatial resolution. This version of ALCC algorithm is adapted for use on Sentinel 2 images with 10 m spatial resolution.

Gradient boosting

Gradient boosting classification is implemented using xboost library. Collection of training data is automated by tresholding spectral indices.

Installation

Important!

Library dependency that must be installed before installing sen2classification is rasterio (and GDAL which is rasterio dependency). Installing sen2classification won't install rasterio.

Simplest way to install GDAL and rasterio is by using conda with conda-forge channel

conda install -c conda-forge gdal rasterio

After that use pip to install sen2classification.

pip install sen2classification

Usage

from sen2classification import ALCC
from sen2classification import GBClassification

# input is Sentinel 2 L2A product folder
alcc = ALCC(product='path to unzipped Sentinel 2 L2A product (.SAFE)', product_type='L2A')
# input is Sentinel 2 L1C product folder
xgb = GBClassification(product='path to unzipped Sentinel 2 L1C product (.SAFE)', product_type='L1C')


# sets up band file paths
alcc.setup_bands()

# swir bands must be resampled to 10m for calculating spectral indices
alcc.resample_swir_to_10m()

# calculate AWEI, NDVI, NDTI and BAEI spectra indices
alcc.calculate_spectral_indices()

# run ALCC algorithm
# final classification raster is saved in current working directory
alcc.run()

# setup and execution is identical for xgb

License

MIT

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

sen2classification-0.0.1.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

sen2classification-0.0.1-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

Details for the file sen2classification-0.0.1.tar.gz.

File metadata

  • Download URL: sen2classification-0.0.1.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for sen2classification-0.0.1.tar.gz
Algorithm Hash digest
SHA256 d366b78d243e55b81a0e1634f812eb78a0260f32af9571c5205dbe66efe99718
MD5 7f91e54e8b61ade65b4fae9c05401024
BLAKE2b-256 cec0f5a66327a1c669db738f03aa79f0965cd426c4fc5fce0c966be7e923257c

See more details on using hashes here.

File details

Details for the file sen2classification-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: sen2classification-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 21.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for sen2classification-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 df3c809267f369acf186688d0df762c9aeb3b913923c9a94ee7f67dedf180c0b
MD5 24cdc8e39f315e812287d50bcd087d30
BLAKE2b-256 7d801cab8f3acc0a650d04239862c95327cd1062a0ad8fee23514ca53d294c48

See more details on using hashes here.

Supported by

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