Skip to content

module process


function crop

1
crop(image, vector, filename=None, filepath=None)

This algorithm allows to clip a raster (.tif) including a satellite image using a vector file, tipically a shapefile.

Parameters:

  • image: This parameter can be a string with the raster path (e.g., r'/home/image/b3.tif') or it can be a rasterio.io.DatasetReader type.

  • vector: Vector file, tipically shapefile, for instance.

  • filename: The image name to be saved.

  • filepath: The path which the image will be stored.

Return:

A raster in your filepath.


function extract

1
extract(image, vector)

This algorithm allows to extract raster values using a vector file (with a Point geometry).

Parameters:

  • image: Optical images. It must be rasterio.io.DatasetReader with 3d or 2d.

  • vector: Vector file, tipically shapefile, for instance.

Return:

A dataframe with raster values obtained.

Note:

This function is usually used to extract raster values to be used on machine learning algorithms.


function confintervalML

1
confintervalML(matrix, image_pred, pixel_size=10, conf=1.96, nodata=None)

The error matrix is a simple cross-tabulation of the class labels allocated by the classification of the remotely sensed data against the reference data for the sample sites. The error matrix organizes the acquired sample data in a way that summarizes key results and aids the quantification of accuracy and area. The main diagonal of the error matrix highlights correct classifications while the off-diagonal elements show omission and commission errors. The cell entries and marginal values of the error matrix are fundamental to both accuracy assessment and area estimation. The cell entries of the population error matrix and the parameters derived from it must be estimated from a sample. This function shows how to obtain a confusion matrix by estimated proportions of area with a confidence interval at 95% (1.96). I strongly recommend reading Olofsson et al. (2014)'s paper for more technical and scientific details on the implementation of this function.

Parameters:

  • matrix: confusion matrix or error matrix in numpy.ndarray.

  • image_pred: Could be an array with 2d (rows, cols). This array should be the image classified with predicted classes. Or, could be a list with number of pixels for each class.

  • pixel_size: Pixel size of the image classified. By default is 10m of Sentinel-2.

  • conf: Confidence interval. By default is 95%.

Return:

Information of confusion matrix by proportions of area, overall accuracy, user's accuracy with confidence interval and estimated area with confidence interval as well.

Reference:

Olofsson, P., Foody, G.M., Herold, M., Stehman, S.V., Woodcock, C.E., and Wulder, M.A. 2014. “Good practices
- for estimating area and assessing accuracy of land change.” Remote Sensing of Environment, Vol. 148: 42–57.
- doi: https://doi.org/10.1016/j.rse.2014.02.015.

Note:

Columns and rows in a confusion matrix indicate reference and prediction respectively. Additionally, the most critical recommendation is that the sampling design should be a probability sampling design. An essential element of probability sampling is that randomization is incorporated into the sample selection protocol. Various probability sampling designs can be applied for precision assessment and area estimation, the most commonly used designs being simple random, stratified random, and systematic (Olofsson et al., 2014).


function print_info

1
print_info(params)

Information: Confusion Matrix by Estimated Proportions of area an uncertainty

Parameters:

  • params: confintervalML result. See the function: https://github.com/ytarazona/scikit-eo/blob/main/scikeo/process.py

Return:

Information of confusion matrix by proportions of area, overall accuracy, user's accuracy with confidence interval and estimated area with confidence interval as well.

Note:

This function was tested using ground-truth values obtained by Olofsson et al. (2014).


This file was automatically generated via lazydocs.