scikeo


Namescikeo JSON
Version 0.2.34 PyPI version JSON
download
home_pagehttps://github.com/yotarazona/scikit-eo
SummaryRemote Sensing Tools
upload_time2024-10-16 16:33:27
maintainerNone
docs_urlNone
authorYonatan Tarazona
requires_python>=3.5
licenseApache Software License 2.0
keywords scikeo
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <!-- #region -->
# scikit-eo: A Python package for Remote Sensing Data Analysis

[![Google Colab](https://colab.research.google.com/assets/colab-badge.svg)]()
[![License: MIT](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![PythonVersion]( https://img.shields.io/badge/python-3.5%20%7C%203.6%20%7C%203.7%20%7C%203.8-green)]()
[![PyPI version](https://badge.fury.io/py/scikeo.svg)](https://badge.fury.io/py/scikeo)
[![Youtube](https://img.shields.io/badge/YouTube-Channel-red)]()
[![Downloads](https://static.pepy.tech/badge/scikeo)](https://pepy.tech/project/scikeo)
[![Downloads](https://raw.githubusercontent.com/yotarazona/scikit-eo/main/docs/images/docs-passing-brightgreen.svg)]()
[![tests](https://github.com/yotarazona/scikit-eo/actions/workflows/tests.yml/badge.svg)](https://github.com/yotarazona/scikit-eo/actions/workflows/tests.yml)
<a href="https://joss.theoj.org/papers/46bccc5be81d7ea886e05807cfe6790c"><img src="https://joss.theoj.org/papers/46bccc5be81d7ea886e05807cfe6790c/status.svg"></a>

<img src="https://raw.githubusercontent.com/yotarazona/scikit-eo/main/docs/images/scikit-eo_logo.jpg" align="right" width="220"/>

# Journal of Open Source Software

## Citation

Please, to cite the ```scikit-eo``` package in publications, use this paper:

Tarazona, Y., Benitez-Paez, F., Nowosad, J., Drenkhan, F., Nowosad, J., and TimanĂ¡, M. (2024). **scikit-eo: A Python package for Remote Sensing Data Analysis**. *Journal of Open Source Software*, 9(99), 6692. DOI: [10.21105/joss.06692](https://joss.theoj.org/papers/10.21105/joss.06692)

<!-- #region -->

# Introduction

Nowadays, remotely sensed data has increased dramatically. Microwaves and optical images with different spatial and temporal resolutions are available and are used to monitor a variety of environmental issues such as deforestation, land degradation, land use and land cover change, among others. Although there are efforts (i.e., Python packages, forums, communities, etc.) to make available line-of-code tools for pre-processing, processing and analysis of satellite imagery, there is still a gap that needs to be filled. In other words, too much time is still spent by many users developing Python lines of code. Algorithms for mapping land degradation through a linear trend of vegetation indices, fusion optical and radar images to classify vegetation cover, and calibration of machine learning algorithms, among others, are not available yet.

Therefore, [scikit-eo](https://github.com/yotarazona/scikit-eo) is a Python package that provides tools for remote sensing. This package was developed to fill the gaps in remotely sensed data processing tools. Most of the tools are based on scientific publications, and others are useful algorithms that will allow processing to be done in a few lines of code. With these tools, the user will be able to invest time in analyzing the results of their data and not spend time on elaborating lines of code, which can sometimes be stressful.

# Tools for Remote Sensing

| Name of functions/classes  | Description|
| -------------------| --------------------------------------------------------------------------|
| **`mla`**          | Machine Learning (Random Forest, Support Vector Machine, Decition Tree, Naive Bayes, Neural Network, etc.)                                                          |
| **`calmla`**       | Calibrating supervised classification in Remote Sensing (e.g., Monte Carlo Cross-Validation, Leave-One-Out Cross-Validation, etc.)                   |
| **`confintervalML`**       | Information of confusion matrix by proportions of area, overall accuracy, user's accuracy with confidence interval and estimated area with confidence interval as well.                                    |
| **`rkmeans`**      | K-means classification                                                    |
| **`calkmeans`**    | This function allows to calibrate the kmeans algorithm. It is possible to obtain the best k value and the best embedded algorithm in kmeans.                               |
| **`pca`**          | Principal Components Analysis                                             |
| **`atmosCorr`**    | Atmospheric Correction of satellite imagery                               |
| **`deepLearning`** | Deep Learning algorithms                                                  |
| **`linearTrend`**  | Linear trend is useful for mapping forest degradation or land degradation |
| **`fusionrs`**     | This algorithm allows to fuse images coming from different spectral sensors (e.g., optical-optical, optical and SAR or SAR-SAR). Among many of the qualities of this function, it is possible to obtain the contribution (%) of each variable in the fused image |
| **`sma`**          | Spectral Mixture Analysis - Classification sup-pixel                      |
| **`tassCap`**      | The Tasseled-Cap Transformation.                                         |

You will find more algorithms!.

# Dependencies used by **scikit-eo**

All dependencies used by ```scikit-eo``` are as follows:

```numpy```, ```pandas```, ```matplotlib```, ```rasterio```, ```seaborn```, ```statsmodels```, ```scikit-learn```, ```scipy```, ```pytest```, ```dbfread```, ```fiona``` and ```geopandas```. By installing ```scikit-eo``` all these packages will be installed!.

# Installation

To use ```scikit-eo``` it is necessary to install it. There are two options:

## 1. From PyPI

**scikit-eo** is available on [PyPI](https://pypi.org/project/scikeo/), so to install it, run this command in your terminal:

```python
pip install scikeo
```

## 2. Installing from source

It is also possible to install the latest development version directly from the GitHub repository with:

```python
pip install git+https://github.com/yotarazona/scikit-eo
```

## containerizing ```scikit-eo```

**Note**: It is a recommended practice to provide some instructions for isolating/containerizing ```scikit-eo```. It would benefit their use and thus avoid that some dependencies are not compatible with others. For example, conda provides an easy solution.

```python
conda create -n scikiteo python = 3.8
```
Then, activate the environment created

```python
conda activate scikiteo
```
Then finally, ```scikit-eo``` can be install within this new environment using via PyPI or from the GitHub repository.

<!-- #endregion -->

# Example

## 1.0 Applying Machine Learning

Libraries to be used:

```python
import rasterio
import numpy as np
from scikeo.mla import MLA
from scikeo.process import extract
import matplotlib.pyplot as plt
import matplotlib as mpl
import geopandas as gpd
from scikeo.plot import plotRGB
from scikeo.writeRaster import writeRaster
```

## 2.0 Optical image

Landsat-8 OLI (Operational Land Imager) will be used to obtain in order to classify using Random Forest (RF). This image, which is in surface reflectance with bands:
- Blue -> B2
- Green -> B3 
- Red -> B4
- Nir -> B5
- Swir1 -> B6
- Swir2 -> B7

This image will be downloaded using the following codes:

```python
import requests, zipfile
from io import BytesIO

# Defining the zip file URL
url = 'https://github.com/yotarazona/data/raw/main/data/01_machine_learning.zip'

# Split URL to get the file name
filename = url.split('/')[-1]

# Downloading the file by sending the request to the URL
req = requests.get(url)

# extracting the zip file contents
file = zipfile.ZipFile(BytesIO(req.content))
file.extractall()
```

## 3.0 Supervised Classification using Random Forest

Image and endmembers

```python
data_dir = "01_machine_learning/"

# satellite image
path_raster = data_dir + "LC08_232066_20190727_SR.tif"
img = rasterio.open(path_raster)

# endmembers
path_endm = data_dir + "endmembers.shp"
endm = gpd.read_file(path_endm)
```

```python
# endmembers
endm = extract(img, endm)
endm
```
<p align="left">
  <a href="https://github.com/yotarazona/scikit-eo"><img src="https://raw.githubusercontent.com/yotarazona/scikit-eo/main/docs/images/endembers.png" alt ="header" width = 75%>
</a>
</p>


Instance of ```mla()```:

```python
inst = MLA(image = img, endmembers = endm)
```

Applying Random Forest:

```python
svm_class = inst.SVM(training_split = 0.7)
```

## 4.0 Results

Dictionary of results

```python
svm_class.keys()
```

Overall accuracy

```python
svm_class.get('Overall_Accuracy')
```

Kappa index

```python
svm_class.get('Kappa_Index')
```

Confusion matrix or error matrix

```python
svm_class.get('Confusion_Matrix')
```

<p align="left">
  <a href="https://github.com/yotarazona/scikit-eo"><img src="https://raw.githubusercontent.com/yotarazona/scikit-eo/main/docs/images/confusion_matrix.png" alt ="header" width = 80%>
</a>
</p>


Preparing the image before plotting

```python
# Let's define the color palette
palette = mpl.colors.ListedColormap(["#2232F9","#F922AE","#229954","#7CED5E"])
```

Applying the ```plotRGB()``` algorithm is easy:

```python
# Let´s plot
fig, axes = plt.subplots(nrows = 1, ncols = 2, figsize = (15, 9))

# satellite image
plotRGB(img, title = 'Image in Surface Reflectance', ax = axes[0])

# class results
axes[1].imshow(svm_class.get('Classification_Map'), cmap = palette)
axes[1].set_title("Classification map")
axes[1].grid(False)
```

<p align="left">
  <a href="https://github.com/yotarazona/scikit-eo"><img src="https://raw.githubusercontent.com/yotarazona/scikit-eo/main/docs/images/classification.png" alt ="header" width = "750">
</a>
</p>

This result shows us how we can use the ```scikit-eo``` python package in order to obtaind a Land Cover map. Following this tutorial is it possible to use different algorithms such as Support Vector Machine, Decision Tree, Neural Networks, amont others.


-   Free software: Apache Software License 2.0
-   Documentation: 

## Acknowledgment

Special thanks to:
- [David Montero Loaiza](https://github.com/davemlz) for the idea of the package name **scikit-eo**.

- [Qiusheng Wu](https://github.com/giswqs) for the suggestions that helped to improve the package.

## Credits

This package was created with [Cookiecutter](https://github.com/cookiecutter/cookiecutter)

## Logo inspiration

The logo on the package is inspired by fog oasis known as "lomas".

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/yotarazona/scikit-eo",
    "name": "scikeo",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": null,
    "keywords": "scikeo",
    "author": "Yonatan Tarazona",
    "author_email": "ytarazona09@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c8/87/92a17a8fd67ba68be77f16a87b80bd1c913928b1e50567b117cd8cafead2/scikeo-0.2.34.tar.gz",
    "platform": null,
    "description": "<!-- #region -->\n# scikit-eo: A Python package for Remote Sensing Data Analysis\n\n[![Google Colab](https://colab.research.google.com/assets/colab-badge.svg)]()\n[![License: MIT](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![PythonVersion]( https://img.shields.io/badge/python-3.5%20%7C%203.6%20%7C%203.7%20%7C%203.8-green)]()\n[![PyPI version](https://badge.fury.io/py/scikeo.svg)](https://badge.fury.io/py/scikeo)\n[![Youtube](https://img.shields.io/badge/YouTube-Channel-red)]()\n[![Downloads](https://static.pepy.tech/badge/scikeo)](https://pepy.tech/project/scikeo)\n[![Downloads](https://raw.githubusercontent.com/yotarazona/scikit-eo/main/docs/images/docs-passing-brightgreen.svg)]()\n[![tests](https://github.com/yotarazona/scikit-eo/actions/workflows/tests.yml/badge.svg)](https://github.com/yotarazona/scikit-eo/actions/workflows/tests.yml)\n<a href=\"https://joss.theoj.org/papers/46bccc5be81d7ea886e05807cfe6790c\"><img src=\"https://joss.theoj.org/papers/46bccc5be81d7ea886e05807cfe6790c/status.svg\"></a>\n\n<img src=\"https://raw.githubusercontent.com/yotarazona/scikit-eo/main/docs/images/scikit-eo_logo.jpg\" align=\"right\" width=\"220\"/>\n\n# Journal of Open Source Software\n\n## Citation\n\nPlease, to cite the ```scikit-eo``` package in publications, use this paper:\n\nTarazona, Y., Benitez-Paez, F., Nowosad, J., Drenkhan, F., Nowosad, J., and Timan\u00e1, M. (2024). **scikit-eo: A Python package for Remote Sensing Data Analysis**. *Journal of Open Source Software*, 9(99), 6692. DOI: [10.21105/joss.06692](https://joss.theoj.org/papers/10.21105/joss.06692)\n\n<!-- #region -->\n\n# Introduction\n\nNowadays, remotely sensed data has increased dramatically. Microwaves and optical images with different spatial and temporal resolutions are available and are used to monitor a variety of environmental issues such as deforestation, land degradation, land use and land cover change, among others. Although there are efforts (i.e., Python packages, forums, communities, etc.) to make available line-of-code tools for pre-processing, processing and analysis of satellite imagery, there is still a gap that needs to be filled. In other words, too much time is still spent by many users developing Python lines of code. Algorithms for mapping land degradation through a linear trend of vegetation indices, fusion optical and radar images to classify vegetation cover, and calibration of machine learning algorithms, among others, are not available yet.\n\nTherefore, [scikit-eo](https://github.com/yotarazona/scikit-eo) is a Python package that provides tools for remote sensing. This package was developed to fill the gaps in remotely sensed data processing tools. Most of the tools are based on scientific publications, and others are useful algorithms that will allow processing to be done in a few lines of code. With these tools, the user will be able to invest time in analyzing the results of their data and not spend time on elaborating lines of code, which can sometimes be stressful.\n\n# Tools for Remote Sensing\n\n| Name of functions/classes  | Description|\n| -------------------| --------------------------------------------------------------------------|\n| **`mla`**          | Machine Learning (Random Forest, Support Vector Machine, Decition Tree, Naive Bayes, Neural Network, etc.)                                                          |\n| **`calmla`**       | Calibrating supervised classification in Remote Sensing (e.g., Monte Carlo Cross-Validation, Leave-One-Out Cross-Validation, etc.)                   |\n| **`confintervalML`**       | Information of confusion matrix by proportions of area, overall accuracy, user's accuracy with confidence interval and estimated area with confidence interval as well.                                    |\n| **`rkmeans`**      | K-means classification                                                    |\n| **`calkmeans`**    | This function allows to calibrate the kmeans algorithm. It is possible to obtain the best k value and the best embedded algorithm in kmeans.                               |\n| **`pca`**          | Principal Components Analysis                                             |\n| **`atmosCorr`**    | Atmospheric Correction of satellite imagery                               |\n| **`deepLearning`** | Deep Learning algorithms                                                  |\n| **`linearTrend`**  | Linear trend is useful for mapping forest degradation or land degradation |\n| **`fusionrs`**     | This algorithm allows to fuse images coming from different spectral sensors (e.g., optical-optical, optical and SAR or SAR-SAR). Among many of the qualities of this function, it is possible to obtain the contribution (%) of each variable in the fused image |\n| **`sma`**          | Spectral Mixture Analysis - Classification sup-pixel                      |\n| **`tassCap`**      | The Tasseled-Cap Transformation.                                         |\n\nYou will find more algorithms!.\n\n# Dependencies used by **scikit-eo**\n\nAll dependencies used by ```scikit-eo``` are as follows:\n\n```numpy```, ```pandas```, ```matplotlib```, ```rasterio```, ```seaborn```, ```statsmodels```, ```scikit-learn```, ```scipy```, ```pytest```, ```dbfread```, ```fiona``` and ```geopandas```. By installing ```scikit-eo``` all these packages will be installed!.\n\n# Installation\n\nTo use ```scikit-eo``` it is necessary to install it. There are two options:\n\n## 1. From PyPI\n\n**scikit-eo** is available on [PyPI](https://pypi.org/project/scikeo/), so to install it, run this command in your terminal:\n\n```python\npip install scikeo\n```\n\n## 2. Installing from source\n\nIt is also possible to install the latest development version directly from the GitHub repository with:\n\n```python\npip install git+https://github.com/yotarazona/scikit-eo\n```\n\n## containerizing ```scikit-eo```\n\n**Note**: It is a recommended practice to provide some instructions for isolating/containerizing ```scikit-eo```. It would benefit their use and thus avoid that some dependencies are not compatible with others. For example, conda provides an easy solution.\n\n```python\nconda create -n scikiteo python = 3.8\n```\nThen, activate the environment created\n\n```python\nconda activate scikiteo\n```\nThen finally, ```scikit-eo``` can be install within this new environment using via PyPI or from the GitHub repository.\n\n<!-- #endregion -->\n\n# Example\n\n## 1.0 Applying Machine Learning\n\nLibraries to be used:\n\n```python\nimport rasterio\nimport numpy as np\nfrom scikeo.mla import MLA\nfrom scikeo.process import extract\nimport matplotlib.pyplot as plt\nimport matplotlib as mpl\nimport geopandas as gpd\nfrom scikeo.plot import plotRGB\nfrom scikeo.writeRaster import writeRaster\n```\n\n## 2.0 Optical image\n\nLandsat-8 OLI (Operational Land Imager) will be used to obtain in order to classify using Random Forest (RF). This image, which is in surface reflectance with bands:\n- Blue -> B2\n- Green -> B3 \n- Red -> B4\n- Nir -> B5\n- Swir1 -> B6\n- Swir2 -> B7\n\nThis image will be downloaded using the following codes:\n\n```python\nimport requests, zipfile\nfrom io import BytesIO\n\n# Defining the zip file URL\nurl = 'https://github.com/yotarazona/data/raw/main/data/01_machine_learning.zip'\n\n# Split URL to get the file name\nfilename = url.split('/')[-1]\n\n# Downloading the file by sending the request to the URL\nreq = requests.get(url)\n\n# extracting the zip file contents\nfile = zipfile.ZipFile(BytesIO(req.content))\nfile.extractall()\n```\n\n## 3.0 Supervised Classification using Random Forest\n\nImage and endmembers\n\n```python\ndata_dir = \"01_machine_learning/\"\n\n# satellite image\npath_raster = data_dir + \"LC08_232066_20190727_SR.tif\"\nimg = rasterio.open(path_raster)\n\n# endmembers\npath_endm = data_dir + \"endmembers.shp\"\nendm = gpd.read_file(path_endm)\n```\n\n```python\n# endmembers\nendm = extract(img, endm)\nendm\n```\n<p align=\"left\">\n  <a href=\"https://github.com/yotarazona/scikit-eo\"><img src=\"https://raw.githubusercontent.com/yotarazona/scikit-eo/main/docs/images/endembers.png\" alt =\"header\" width = 75%>\n</a>\n</p>\n\n\nInstance of ```mla()```:\n\n```python\ninst = MLA(image = img, endmembers = endm)\n```\n\nApplying Random Forest:\n\n```python\nsvm_class = inst.SVM(training_split = 0.7)\n```\n\n## 4.0 Results\n\nDictionary of results\n\n```python\nsvm_class.keys()\n```\n\nOverall accuracy\n\n```python\nsvm_class.get('Overall_Accuracy')\n```\n\nKappa index\n\n```python\nsvm_class.get('Kappa_Index')\n```\n\nConfusion matrix or error matrix\n\n```python\nsvm_class.get('Confusion_Matrix')\n```\n\n<p align=\"left\">\n  <a href=\"https://github.com/yotarazona/scikit-eo\"><img src=\"https://raw.githubusercontent.com/yotarazona/scikit-eo/main/docs/images/confusion_matrix.png\" alt =\"header\" width = 80%>\n</a>\n</p>\n\n\nPreparing the image before plotting\n\n```python\n# Let's define the color palette\npalette = mpl.colors.ListedColormap([\"#2232F9\",\"#F922AE\",\"#229954\",\"#7CED5E\"])\n```\n\nApplying the ```plotRGB()``` algorithm is easy:\n\n```python\n# Let\u00b4s plot\nfig, axes = plt.subplots(nrows = 1, ncols = 2, figsize = (15, 9))\n\n# satellite image\nplotRGB(img, title = 'Image in Surface Reflectance', ax = axes[0])\n\n# class results\naxes[1].imshow(svm_class.get('Classification_Map'), cmap = palette)\naxes[1].set_title(\"Classification map\")\naxes[1].grid(False)\n```\n\n<p align=\"left\">\n  <a href=\"https://github.com/yotarazona/scikit-eo\"><img src=\"https://raw.githubusercontent.com/yotarazona/scikit-eo/main/docs/images/classification.png\" alt =\"header\" width = \"750\">\n</a>\n</p>\n\nThis result shows us how we can use the ```scikit-eo``` python package in order to obtaind a Land Cover map. Following this tutorial is it possible to use different algorithms such as Support Vector Machine, Decision Tree, Neural Networks, amont others.\n\n\n-   Free software: Apache Software License 2.0\n-   Documentation: \n\n## Acknowledgment\n\nSpecial thanks to:\n- [David Montero Loaiza](https://github.com/davemlz) for the idea of the package name **scikit-eo**.\n\n- [Qiusheng Wu](https://github.com/giswqs) for the suggestions that helped to improve the package.\n\n## Credits\n\nThis package was created with [Cookiecutter](https://github.com/cookiecutter/cookiecutter)\n\n## Logo inspiration\n\nThe logo on the package is inspired by fog oasis known as \"lomas\".\n",
    "bugtrack_url": null,
    "license": "Apache Software License 2.0",
    "summary": "Remote Sensing Tools",
    "version": "0.2.34",
    "project_urls": {
        "Homepage": "https://github.com/yotarazona/scikit-eo"
    },
    "split_keywords": [
        "scikeo"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3cc77659318df747c44feda42c7e3d8a0275c2141474d74e39d9ad222605ccaf",
                "md5": "c552b8ac7465c8afe2fc4bd0bd7c6f79",
                "sha256": "2413b9b661b26a87d73b5cfd3178e829a6760891381f3b11a13bf5ee2549c6fd"
            },
            "downloads": -1,
            "filename": "scikeo-0.2.34-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c552b8ac7465c8afe2fc4bd0bd7c6f79",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.5",
            "size": 38852,
            "upload_time": "2024-10-16T16:33:25",
            "upload_time_iso_8601": "2024-10-16T16:33:25.626344Z",
            "url": "https://files.pythonhosted.org/packages/3c/c7/7659318df747c44feda42c7e3d8a0275c2141474d74e39d9ad222605ccaf/scikeo-0.2.34-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c88792a17a8fd67ba68be77f16a87b80bd1c913928b1e50567b117cd8cafead2",
                "md5": "f5a2a77d942f25daf63e36707ce590a4",
                "sha256": "475e296617aca8a0ede65477fbb07b0e2f5abae2db979ff7f35fe4e91fc15d1d"
            },
            "downloads": -1,
            "filename": "scikeo-0.2.34.tar.gz",
            "has_sig": false,
            "md5_digest": "f5a2a77d942f25daf63e36707ce590a4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5",
            "size": 35324,
            "upload_time": "2024-10-16T16:33:27",
            "upload_time_iso_8601": "2024-10-16T16:33:27.420613Z",
            "url": "https://files.pythonhosted.org/packages/c8/87/92a17a8fd67ba68be77f16a87b80bd1c913928b1e50567b117cd8cafead2/scikeo-0.2.34.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-16 16:33:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yotarazona",
    "github_project": "scikit-eo",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "scikeo"
}
        
Elapsed time: 0.32726s