Extract the band information of raster data with python

Introduction

I wanted to extract the following band information that can be confirmed in the properties when GPV (raster data) is opened in QGIS with python, so a memo of how to do it. image.png

Method

from osgeo import gdal
data = gdal.Open("path")

band =Number of bands
data.GetRasterBand(band).GetMetadata()

result

The results are retrieved in dictionary format. The following is the information of band 1.

{'GRIB_COMMENT': 'Geopotential height [gpm]', 'GRIB_DISCIPLINE': '0(Meteorological)', 'GRIB_ELEMENT': 'HGT', 'GRIB_FORECAST_SECONDS': '0 sec', 'GRIB_IDS': 'CENTER=34(Tokyo) SUBCENTER=0 MASTER_TABLE=2 LOCAL_TABLE=1 SIGNF_REF_TIME=1(Start_of_Forecast) REF_TIME=2017-12-05T00:00:00Z PROD_STATUS=0(Operational) TYPE=1(Forecast)', 'GRIB_PDS_PDTN': '0', 'GRIB_PDS_TEMPLATE_ASSEMBLED_VALUES': '3 5 1 31 255 0 50 1 0 100 -2 1000 255 -127 -2147483647', 'GRIB_PDS_TEMPLATE_NUMBERS': '3 5 1 31 255 0 0 50 1 0 0 0 0 100 130 0 0 3 232 255 255 255 255 255 255', 'GRIB_REF_TIME': '1512432000 sec UTC', 'GRIB_SHORT_NAME': '100000-ISBL', 'GRIB_UNIT': '[gpm]', 'GRIB_VALID_TIME': '1512432000 sec UTC', 'STATISTICS_MAXIMUM': '250.91836547852', 'STATISTICS_MEAN': '118.31441361789', 'STATISTICS_MINIMUM': '-55.081642150879', 'STATISTICS_STDDEV': '60.506839414168', 'STATISTICS_VALID_PERCENT': '100'}

It looks like this to make it easier to see GRIB_COMMENT : Geopotential height [gpm] GRIB_DISCIPLINE : 0(Meteorological) GRIB_ELEMENT : HGT GRIB_FORECAST_SECONDS : 0 sec GRIB_IDS : CENTER=34(Tokyo) SUBCENTER=0 MASTER_TABLE=2 LOCAL_TABLE=1 SIGNF_REF_TIME=1(Start_of_Forecast) REF_TIME=2017-12-05T00:00:00Z PROD_STATUS=0(Operational) TYPE=1(Forecast) GRIB_PDS_PDTN : 0 GRIB_PDS_TEMPLATE_ASSEMBLED_VALUES : 3 5 1 31 255 0 50 1 0 100 -2 1000 255 -127 -2147483647 GRIB_PDS_TEMPLATE_NUMBERS : 3 5 1 31 255 0 0 50 1 0 0 0 0 100 130 0 0 3 232 255 255 255 255 255 255 GRIB_REF_TIME : 1512432000 sec UTC GRIB_SHORT_NAME : 100000-ISBL GRIB_UNIT : [gpm] GRIB_VALID_TIME : 1512432000 sec UTC STATISTICS_MAXIMUM : 250.91836547852 STATISTICS_MEAN : 118.31441361789 STATISTICS_MINIMUM : -55.081642150879 STATISTICS_STDDEV : 60.506839414168 STATISTICS_VALID_PERCENT : 100

I was able to get through safely.

Please see here for details of each information.

Recommended Posts

Extract the band information of raster data with python
Extract the table of image files with OneDrive & Python
Extract the xz file with python
Try scraping the data of COVID-19 in Tokyo with Python
[Homology] Count the number of holes in data with Python
Try to extract the features of the sensor data with CNN
Check the existence of the file with python
Recommendation of Altair! Data visualization with Python
PhytoMine-I tried to get the genetic information of plants with Python
Try to image the elevation data of the Geographical Survey Institute with Python
I tried to get the movie information of TMDb API with Python
Prepare the execution environment of Python3 with Docker
[Note] Export the html of the site with python.
Calculate the total number of combinations with python
Check the date of the flag duty with Python
Get CPU information of Raspberry Pi with Python
The story of reading HSPICE data in Python
Convert the character code of the file with Python3
[Python] Determine the type of iris with SVM
Extract data from a web page with Python
Data analysis with python 2
the zen of Python
Data analysis with Python
Location information data display in Python --Try plotting with the map display library (folium)-
Align the number of samples between classes of data for machine learning with Python
[Introduction to Python] How to get the index of data with a for statement
Learn Nim with Python (from the beginning of the year).
Add information to the bottom of the figure with Matplotlib
Destroy the intermediate expression of the sweep method with Python
Visualize the range of interpolation and extrapolation with python
Calculate the regression coefficient of simple regression analysis with python
Challenge principal component analysis of text data with Python
Information for controlling the motor with Python on RaspberryPi
Not being aware of the contents of the data in python
Summary of the basic flow of machine learning with Python
Understand the status of data loss --Python vs. R
Get the operation status of JR West with Python
[Basics of data science] Collecting data from RSS with python
[Python Data Frame] When the value is empty, fill it with the value of another column.
Get information equivalent to the Network tab of Chrome developer tools with Python + Selenium
Sample data created with python
Towards the retirement of Python2
Extract Twitter data with CSV
Get Youtube data with python
About the ease of Python
Call the API with python3.
About the features of Python
Get Alembic information with Python
The Power of Pandas: Python
Read json data with python
I tried to find the entropy of the image with python
I tried "gamma correction" of the image with Python + OpenCV
Extract template of EML file saved from Thunderbird with python3.7
Let's utilize the railway data of national land numerical information
Visualize the results of decision trees performed with Python scikit-learn
Notes on handling large amounts of data with python + pandas
I wrote the basic grammar of Python with Jupyter Lab
Tank game made with python About the behavior of tanks
I evaluated the strategy of stock system trading with Python.
Check the scope of local variables with the Python locals function.
Let's touch the API of Netatmo Weather Station with Python. #Python #Netatmo