程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python remote sensing image processing application (20): python+gdal batch extracts multi band images into single band images

編輯:Python

1. Achieve the goal

Batch multi band images are extracted into each single band image

Running environment :windows10  pycharm  python3.7.7  GDAL-3.2.3-cp37-cp37m-win_amd64.whl Bag, etc .

2. Implementation code

"""
This code will remove the background value of remote sensing image
"""
import numpy as np
from osgeo import gdal, gdalconst
import os
# Normalize the remote sensing image Write function
def GetEnvolopePoint(inputpath,output_filepath):
gdal.UseExceptions()
ds = gdal.Open(inputpath)
band01 = ds.GetRasterBand(1)
im_width, im_height = band01.XSize, band01.YSize
print(inputpath," The image size is :",im_width, im_height)
dim_z = ds.RasterCount # Number of image channels
if dim_z>5:
dim_z=5 # Just before extraction 5 Band
for i in range(1, dim_z + 1):
band = ds.GetRasterBand(i)
band_array = band.ReadAsArray()
print("Image Shape:", band_array.shape)

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved