Python GDAL: Opening and Inspecting Landsat Data

This code snippet showcases how to open a Landsat GeoTIFF image using the GDAL library in Python. It also demonstrates how to check the type of the opened dataset.

from osgeo import gdal

filepath = 'LandsatData/LC81910182016153LGN00_sr_band4.tif'

# Open the file:
raster = gdal.Open(filepath)

# Check type of the variable 'raster'
print(type(raster))

Output:

<class 'osgeo.gdal.Dataset'>

This code first imports the GDAL library using from osgeo import gdal. Then, it defines the filepath to the Landsat GeoTIFF file. The gdal.Open(filepath) function opens the file and stores the dataset in the raster variable. Finally, the type(raster) command prints the type of the variable, which is 'osgeo.gdal.Dataset'. This confirms that the opened file is a GDAL Dataset object.

Key Points:

  • GDAL: The Geospatial Data Abstraction Library (GDAL) is a powerful open-source library for working with geospatial data formats.
  • Landsat: Landsat is a series of Earth observation satellites that provide valuable data for various applications.
  • GeoTIFF: The GeoTIFF format is a popular format for storing georeferenced raster images.
  • Dataset: In GDAL, a Dataset object represents a geospatial file that can be accessed and manipulated using various functions.
Python GDAL: Opening and Inspecting Landsat Data

原文地址: https://www.cveoy.top/t/topic/oVlk 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录