GHSL Land Cover python module
Project description
GHSL Land Cover Service
GHS-LC-SERV (GHSL Land Cover Service) is an end-to-end, fully automated Earth Observation processing and analysis pipeline for generating custom land cover maps from Sentinel-2 data archives.
Quick start
The classification can be done on S2 tiles (files zip or SAFE directories) or on S2 mosaics (GeoTIFF format).
from pathlib import Path
from ghslc import ghslc
# Sentinel 2 file to classify
s2_file = Path('S2A_MSIL1C_20191210T101411_N0208_R022_T32TQM_20191210T104357.zip')
# Training configuration as yaml file
training_file = Path('training_CGLS.yml')
# Target classes to extract from the classification
target_classes = [
[80, 200], # Permanent water bodies
[111, 112, 113, 114, 115, 116, 121, 122, 123, 124, 125, 126], # Forests
40, # Cultivated and managed vegetation/agriculture (cropland)
50, # Urban / built up
]
# Output folder
output = Path('/tmp')
results = ghslc.generate_classification_from_safe(
filesafe=s2_file,
workspace=output,
training=training_file,
classes=target_classes,
)
Install
The easier way to install dependencies is using conda:
conda env create -f environment.yml
Activate the conda environment:
conda activate ghslc
Install ghslc package:
pip install ghslc
Test
Simply install tox with:
pip install tox
Then run the tests in python 3.10:
tox -e py310
This will build, install and test the project in a dedicated python 3.10 environment with all needed dependencies. The tests should take few minutes to complete.
If you want to run it for all supported python versions type:
tox
This takes longer, but it should be less than 30 minutes.
Licensing
This project is licensed under the GPLv3 License.
Copyright (c) 2021, European Commission, Joint Research Centre. All rights reserved.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.