Processing satellite data directly from TAR files.
PyRSGIS is a powerful module to read, manipulate and export geo-rasters. The module is built on the GDAL library, and is very efficient for various geospatial analysis. Please do not use this package for commercial purpose without my explicit permission. Researchers/ academicians are welcomed for feedback and technical support.
The module is capable of processing Landsat data from the downloaded TAR files itself.
Please find few example below:
Let's import the module by using the below code
import pyrsgis as rg
We will first start with reading raster and perform some basic operations.
Make sure your current working directory is the same where the raster files are located, if not use the following command:
Please skip the above two lines of code if the directory is already set to the files location.
To read the TAR file directly:
yourData = rg.readtar("yourFilename.tar.gz")
Similarly, stacked TIFF file can be read:
yourData = rg.readtif("yourFilename.tif")
After the above code, various properties of the raster can be assessed.
will give you the number of rows and columns.
The number of bands can be checked using:
The satellite sensor can also be determined.
If the above code shows the correct satellite sensor correctly, then this getting this should be easy:
This will show correctly the band number for available bands.
Any particular band can be extarcted using:
yourBand = yourData.getband(bandNumber)
The above code returns the band as array which can be visualised using:
The map can directly be saved as an image.
Map title can also be assigned:
display(yourBand, maptitle='Your Map Title')
The extracted band can be exported using:
This saves the extracted band to the same directory.
If exporting a float data type (raster with decimal values), please define the datatype explicitly, default is 'int':
yourData.export(yourBand, "yourOutputFilename.tif", datatype='float')
The NDVI (Normalised Difference Vegetaton Index) can be computed easily.
yourndvi = yourData.ndvi()
This returns the NDVI array,which can be exported using the same command used for the band above.
Any normalised difference indev can be computed using:
yourIndex = yourData.nordif(bandNumber2, bandNumber1)
Which performs (band2-band1)/(band2+band1) in the back end.
yourRaster.export(yourndvi, 'yourNDVI.tif', datatype='float')
Be careful that the NDVI is of float datatype, whereas the raw bands are integer datatype. Float data export uses more space on hard drive, so the default has been set to integer. Therefore, to export any float datatype, the argument should be passed explicitly.
Release history Release notifications
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size & hash SHA256 hash help||File type||Python version||Upload date|
|pyrsgis-0.1.9-py3-none-any.whl (8.6 kB) Copy SHA256 hash SHA256||Wheel||py3|
|pyrsgis-0.1.9.tar.gz (6.9 kB) Copy SHA256 hash SHA256||Source||None|