Python | Data Science | Machine Learning
Satellite Imagery Analysis 101: Handling TIFF Files
A detailed explanation of handling satellite imagery in the format of .tiff
files using Python.
There is no need to articulate the expanding applications of Satellite and Hyperspectral Imagery which range from our daily necessities such as food and water to space exploration. Thereby we store the said data in different file formats based on utilization such as Tag Image File Format(.tiff
), Binary MatLab file format(.mat
), e.t.c.
This article walkthrough the readers on the handling of satellite imagery in the .tiff
file format.
Table of Contents
- Introduction
- Handling Satellite Imagery with
.tiff
format - Writing data into
.mat
file format - Conclusion
Introduction
The Tag Image File Format(.tiff
) is one of the widely to store high-quality satellite image data to avoid lossy file formats which means they are larger than the most but don’t lose the information.
To demonstrate the data handling, we are going to use the Sundarbans satellite imagery which is captured by the Sentinel-2 satellite on 27 January 2020 which has 12 bands and a classification map, and different satellite indices. The visualization of the 12 bands is shown below.
The data used in the article can be accessed through the below GitHub repository.
Handling Satellite Imagery with TIFF
To read the satellite images in TIFF, we are going to use the rasterio python package which allows us to access geospatial raster data and to do various operations.
To read the satellite images in TIFF, we use open()
the method which acts similar to the standard open()
method in python. The below code shows how to read multiple satellite bands and save them into a three-dimensional array using numpy. Lines 2–14 show how to read the multiple TIFF satellite data using rasterio.open()
method.
Writing data into .mat
file format
The .mat
file format is widely used across the geo-spatial data science community to save data in binary format. To single or multidimensional data into MAT format, we are going to use the savemat
method from scipy
package.
The savemat()
method primarily takes two parameters:
- file_name: The filename of the data to be written.
- mdict: A dictionary to save mat file variables.
The below code shows how to read a satellite image in the TIFF using rasterio.open()
method and write the data into MAT file format using scipy.io.savemat()
method with the file name as ‘classification_map.mat’.
Conclusion
The article demonstrates how to read single or multiple satellite image data in TIFFF and write them into MAT file format using python. The detailed code presented in the article can be accessed as a jupyter notebook through below GitHub repository.
Related Articles