Skip to main content

python implementation of COntinuous monitoring of Land disturbances algorithm

Project description

PYCOLD

GithubActions Pypi Downloads

A Python library for COntinuous monitoring of Land Disturbance (COLD) and its extension algorithms at the speed of C language

The base algorithms were mostly written using C wrapped in Python, and have been verified with MATLAB version. The C codes of the package were partially modified from C-CCDC developed by USGS.

This library provides:

  1. Original COntinuous monitoring of Land Disturbance (COLD): a upgraded CCDC algorithm proposed by Dr.Zhe Zhu for offline satellite-based time-series analysis

  2. Stochastic Continuous Change Detection (S-CCD, a near real-time and short-memory implementation of COLD)

  3. Object-based COLD (OB-COLD), integrating spatial information into COLD by using a ‘change object’ view

The recent applications of S-CCD and OB-COLD could be found in CONUS Land Watcher

1. Pre-work

Clone github repo to your local code directory for the first use:

git clone https://github.com/GERSL/pycold.git

Or you call pull the recent repo if you want to update the existing pycold repo:

git pull origin devel:devel

2. Installation

The steps to install this library in development mode are consolidated into a single script: run_developer_setup.sh. On debian-based systems, this will install all of the developer requirements and ensure you are setup with a working opencv-python-headless and gdal Python modules, as well as other requirements and then it will compile and install pycold in editable development mode.

The following is an overview of these details and alternative choices that could be made.

2.1 Install Required Libraries

The ZLIB, GSL libraries are required.

For Ubuntu/Debian systems, they can be installed via:

sudo apt-get update
sudo apt-get install build-essential  -y
sudo apt-get install zlib1g-dev -y
sudo apt-get install gfortran -y
sudo apt-get install libgsl-dev -y

On CentOS systems run:

sudo apt-get install gcc gcc-c++ make  -y
sudo apt-get install zlib-devel -y
sudo apt-get install gcc-gfortran -y
# Yum provides an gsl 1.5, but we need 2.7
# sudo apt-get install gsl-devel -y
curl https://ftp.gnu.org/gnu/gsl/gsl-2.7.1.tar.gz  > gsl.tar.gz && tar xfv gsl.tar.gz && cd gsl-2.7.1 && ./configure --prefix=/usr --disable-static && make && make install

2.2 Compile and Install PYCOLD

The following instructure assume you are inside a Python virtual environment (e.g. via conda or pyenv).

# Install required packages
pip install -r requirements.txt

Note that in all cases gdal will need to be manually installed. The following step will install GDAL from a custom pypi server containing precompiled wheels.

# Install GDAL (note-this must be done manually)
pip install -r requirements/gdal.txt

Additionally, to access the cv2 module, pycold will require either opencv-python or opencv-python-headless, which are mutually exclusive. This is exposed as optional dependencies in the package via either “graphics” or “headless” extras. Headless mode is recommended as it is more compatible with other libraries. These can be obtained manually via:

pip install -r requirements/headless.txt

# XOR (choose only one!)

pip install -r requirements/graphics.txt

Option 1: Install in development mode

For details on installing in development mode see the developer install instructions.

We note that all steps in the above document and other minor details are consolidated in the run_developer_setup.sh script.

Option 2: Build and install a wheel

Scikit-build will invoke CMake and build everything. (you may need to remove any existing _skbuild directory).

python -m build --wheel .

Then you can pip install the wheel (the exact path will depend on your system and version of python).

pip install dist/pycold-0.1.0-cp38-cp38-linux_x86_64.whl

You can also use the build_wheels.sh script to invoke cibuildwheel to produce portable wheels that can be installed on different than they were built on. You must have docker and cibuildwheel installed to use this.

Option 3: build standalone binaries with CMake by itself (recommended for C development)

mkdir -p build
cd build
cmake ..
make

Option 4: Use a docker image.

This repo provides dockerfiles that illustrate a reproduceable method for compling and installing PYCOLD. See dockerfiles/README.rst for details.

3. Using pycold for pixel-based processing

COLD:

from pycold import cold_detect
cold_result = cold_detect(dates, blues, greens, reds, nirs, swir1s, swir2s, thermals, qas)

S-CCD:

# require offline processing for the first time
from pycold import sccd_detect, sccd_update
sccd_pack = sccd_detect(dates, blues, greens, reds, nirs, swir1s, swir2s, thermals, qas)

# then use sccd_pack to do recursive and short-memory NRT update
sccd_pack_new = sccd_update(sccd_pack, dates, blues, greens, reds, nirs, swir1s, swir2s, thermals, qas)

Q&A

Q1: Has pycold been verified with original Matlab codes?

Re: yes, multiple rounds of verification have been done. Comparison based on two testing tiles shows that pycold and Matlab version have smaller than <2% differences for breakpoint detection and <2% differences for harmonic coefficients; the accuracy of pycold was also tested against the same reference dataset used in the original COLD paper (Zhu et al., 2020), and pycold reached the same accuracy (27% omission and 28% commission) showing that the discrepancy doesn’t hurt accuracy. The primary source for the discrepancy is mainly from the rounding: MATLAB uses float64 precision, while pycold chose float32 to save the run-time computing memory and boost efficiency.

Q2: how much time for production of a tile-based disturbance map (5000*5000 pixels) using pycold?

Re: I tested it in UCONN HPC environment (200 EPYC7452 cores): for processing a 40-year Landsat ARD tile (1982-2021), the stacking typically takes 15 mins; per-pixel COLD processing costs averagely 1 hour; exporting maps needs 7 mins.

4. Citations

If you make use of the algorithms in this repo (or to read more about them), please cite (/see) the relevant publications from the following list:

[COLD] Zhu, Z., Zhang, J., Yang, Z., Aljaddani, A. H., Cohen, W. B., Qiu, S., & Zhou, C. (2020). Continuous monitoring of land disturbance based on Landsat time series. Remote Sensing of Environment, 238, 111116.

[S-CCD] Ye, S., Rogan, J., Zhu, Z., & Eastman, J. R. (2021). A near-real-time approach for monitoring forest disturbance using Landsat time series: Stochastic continuous change detection. Remote Sensing of Environment, 252, 112167.

[OB-COLD] Ye, S., Zhu, Z., & Cao, G., (2022). Object-based continuous monitoring of land disturbance. Remote Sensing of Environment (in revision)

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

pycold-0.1.2.tar.gz (3.8 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pycold-0.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pycold-0.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pycold-0.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.3 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

pycold-0.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.3 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

Details for the file pycold-0.1.2.tar.gz.

File metadata

  • Download URL: pycold-0.1.2.tar.gz
  • Upload date:
  • Size: 3.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for pycold-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b0b158579dc807d17906c7e829f6918b9e3a93d17a10d68fa80520667a8f119b
MD5 f2170336421e9cbb5923226ab3edae63
BLAKE2b-256 6429940334a3e0e6d0e96d74bb8e4d9fcf88d71c017982fcb5d9da25a1eb68b1

See more details on using hashes here.

File details

Details for the file pycold-0.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pycold-0.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e73122a7af2e7248a43f5013d8180ed3ade92a54a2ce8912bf4a8de9023e8774
MD5 d513ec146b0726e7c799e2717c584cbb
BLAKE2b-256 1e7240ed62b72b58a1386f0c177ca454791c5f668542b4edde2e79ce56bd046f

See more details on using hashes here.

File details

Details for the file pycold-0.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pycold-0.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 573026df4862aee86813876528dab57924486b4e2385d981b40368104a81112c
MD5 6cb4c77b808ddde25dcf14ca47019620
BLAKE2b-256 0490a68954b62c6f09e805d1319efab690343f922da3cf0b0b1c80efad7964de

See more details on using hashes here.

File details

Details for the file pycold-0.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pycold-0.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c69dc17a0da2c67a8b8ae19ed861082eae894cf32e12a564c4b6a43ccab99ead
MD5 c06e1ceff0540799b7f47a064cb223d0
BLAKE2b-256 928e484db008ff6284b1393e34572bf98812c954bcf75b6d03965d99d4042eb3

See more details on using hashes here.

File details

Details for the file pycold-0.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pycold-0.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4ccd85868dad0d74c42d508bee5980f1b199c7b14b2c1f5c94305e7a2bc364ee
MD5 aa9196b2db9a1394a842de3911f89e83
BLAKE2b-256 0336a12f5eeb12f053b4bfb3df1848dabdaef12fa153e623d8a660910b6bc505

See more details on using hashes here.

Supported by

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