rindcalc
Raster Index Calculator
rind calc is a python package created to allow raster index calculation using Landsat-8 using gdal and numpy. Landsat bands are pulled directly from file downloaded from USGS containing all bands in landsat scene. Since rindcalc only requires the file in which Landsat-8 bands are contained instead of each individual band to be specified, it allows for easy, quick, and seamless index calculations from Landsat-8 imagery.
Indices: AWEIsh, AWEInsh, NDMI, MNDWI, NDVI, GNDVI, SAVI, NDBI, NDBaI, NBLI, EBBI, UI, NBRI
K means unsupervised classification module utilizes sci-kit learn's MiniBatchKMeans which provides significantly faster computation times than the standard K-means algorithm, but with slightly worse result [1]. 'No Data' values are populated with the median value of the array as the classification algorithm does not work with numpy arrays that contain 'nan' values.
Dependencies
- GDAL (v 3.0.0 or greater)
- numpy (v 1.0.0 or greater)
- sci-kit learn ( v (0.22.1 or greater))
Installation
Windows
pip install rindcalc
For Windows installation gdal wheels must be installed first.
Modules
Index Modules
- AWEIsh(landsat_dir, aweish_out)
- AWEInsh(landsat_dir, aweinsh_out)
- NDMI(landsat_dir, ndmi_out)
- MNDWI(landsat_dir, mndwi_out)
- NDVI(landsat_dir, ndvi_out)
- GNDVI(landsat_dir)
- SAVI(landsat_dir, soil_brightness, savi_out)
- NDBI(landsat_dir, ndbi_out)
- NDBaI(landsat_dir, ndbai_out)
- NBLI(landsat_dir, nbli_out)
- EBBI(landsat_dir, ebbi_out)
- UI(landsat_dir, ui_out )
- NBRI(landsat_dir, nbri_out)
landsat_dir = Landsat-8 folder that contains all bands
*_out = out file raster will be saved as
i.e. Landsat-8 folder structure:
.
|--LC08_L1TP_091086_20191222_20191223_01_RT Landsat Folder ex. #1
| |-- LC08_L1TP_091086_20191222_20191223_01_RT_B1.TIF
| |-- LC08_L1TP_091086_20191222_20191223_01_RT_B2.TIF
| |-- LC08_L1TP_091086_20191222_20191223_01_RT_B3.TIF
| |-- ...
|-- 2019_12_22 Landsat Folder ex. #2
| |-- LC08_L1TP_091086_20191222_20191223_01_RT_B1.TIF
| |-- LC08_L1TP_091086_20191222_20191223_01_RT_B2.TIF
| |-- LC08_L1TP_091086_20191222_20191223_01_RT_B3.TIF
| |-- ...
K Means Classification Module
- k_means(input_raster, out_raster, clusters, itr, batch_size)
clusters = Number of classes wanted
itr = Number of iterations to perform
batch_size = Size of mini batches
EX:
import rindcalc as rc
landsat_dir = 'C:/.../.../LC08_L1TP_091086_20191222_20191223_01_RT'
ndvi_out = 'C:/.../.../NDVI_1.tif'
rc.NDVI(landsat_dir, ndvi_out)
OR:
import rindcalc as rc
rc.NDVI(landsat_dir = 'C:/.../.../2019_12_22', ndvi_out = 'C:/.../.../NDVI_2.tif')
KMEANS EX:
import rindcalc as rc
input_raster = 'C:/.../.../NDVI.tif'
out_raster = 'C:/.../.../NDVI_K.TIF'
clusters = 2
itr = 10
batch_size = 50
rc.k_means(input_raster, out_raster, clusters, itr, batch_size)
Landsat-8 Bands
| Band Number | Name | µm | Resolution |
|---|---|---|---|
| 1 | Coastal/Aerosal | 0.433–0.453 | 30 m |
| 2 | Blue | 0.450–0.515 | 30 m |
| 3 | Green | 0.525–0.600 | 30 m |
| 4 | Red | 0.630–0.680 | 30 m |
| 5 | NIR | 0.845–0.885 | 30 m |
| 6 | SWIR 1 | 1.560–1.660 | 30 m |
| 7 | SWIR 2 | 2.100–2.300 | 30 m |
| 8 | Panchromatic | 0.500–0.680 | 15 m |
| 9 | Cirrus | 1.360–1.390 | 30 m |
| 10 | TIR 1 | 10.6-11.2 | 100 m |
| 11 | TIR 2 | 11.5-12.5 | 100 m |
Indices
Water
-
AWEIsh = ((Blue + 2.5 * Green - 1.5 * (NIR + SWIR1) - 0.25 * SWIR2)) / (Blue + Green + NIR + SWIR1 + SWIR2)
-
AWEInsh = ((4 * (green_band - swir1_band) - (0.25 * nir_band + 2.75 * swir1_band)) / (green_band + swir1_band + nir_band))
-
NDWI = ((nir_band - swir1_band) / (nir_band + swir1_band))
-
MNDWI = ((Green - SWIR1) / (Green + SWIR1))
Moisture
- NDMI = ((NIR - SWIR1) / (NIR + SWIR1))
Vegetation
-
NDVI = ((NIR - Red) / (NIR + Red))
-
Green NDVI (GNDVI) = ((nir_band - green_band) / (nir_band + green_band))
-
SAVI = ((NIR - Red) / (NIR + Red + L)) x (1 + L)
- L = Soil Brightness Factor
-
MSAVI2 = (((2 * nir_band + 1) - (np.sqrt(((2 * nir_band + 1)**2) - 8 * (nir_band - red_band)))) / 2)
Urban/Landscape
-
NDBI = (SWIR1 - NIR) / (SWIR1 + NIR)
-
NDBaI = ((SWIR1 - TIR) / (SWIR1 + TIR))
-
NBLI = ((Red - TIR) / (Red + TIR))
-
EBBI = ((swir1_band - nir_band) / (10 * (np.sqrt(swir1_band + tir_band))))
-
UI = ((swir2_band - nir_band) / (swir2_band + nir_band))
Fire
- NBRI = ((nir_band - swir2_band) / (nir_band + swir2_band))
Metadata
Release files for rindcalc 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rindcalc-1.1.1.tar.gz | 8.7 kB | Without provenance | Details for rindcalc-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rindcalc-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for rindcalc-1.1.1-py3-none-any.whl |
Total release size: 35.9 kB
Release files / rindcalc-1.1.1.tar.gz
| Download URL | rindcalc-1.1.1.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e8faf35fbc4367b81cd03f255dfd2d108a7b0efeb615d3437df29f2dc4c0404
|
|
BLAKE2b-256 checksum How to use checksums |
debd58e2aaa66b63662c8f75da9d2f9982c0234d8ebc4ffae42005fd4e2ac037
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
|
Release files / rindcalc-1.1.1-py3-none-any.whl
| Download URL | rindcalc-1.1.1-py3-none-any.whl |
|---|---|
| Size | 27.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ac5f0482851cd174c7b7ef63ab2459d35f43e33ea0158fd89850ace94962c06e
|
|
BLAKE2b-256 checksum How to use checksums |
e9b08cc06b500168f0c958e8aa0a741567911557fea7f689bf930a23864d775a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
|
Security for rindcalc 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.