이전 자료하고는 조금 버전업된 코드 공유해드려요.
python에서 tiff metadata 추출 source 공유해드려요.
import os
from osgeo import gdal
filename = "C:\\temo\\"
# raster = gdal.Open(filename)
for x in os.listdir(filename):
if '.tif' in x:
print('-----input : ' + (x) + '-----')
raster = gdal.Open(filename + (x))
# Projection
# print(raster.GetProjection())
Projection = "Projection : EPSG5179"
# Dimensions
RasterColumCount = raster.RasterXSize
XCol = "XColumCount : " + str(RasterColumCount)
RasterRowCount = raster.RasterYSize
YRow = "YRowCount : " + str(RasterRowCount)
# Number of bands
Band = "Bands : " + str(raster.RasterCount)
# Cell Information
CellI = raster.GetGeoTransform()
# print(CellI)
pixelSizeX = CellI[1]
pixelSizeY = -CellI[5]
pixelX = "pixelSizeX : " + str(pixelSizeX*100)
pixelY = "pixelSizeY : " + str(pixelSizeY*100)
# Extent
ExtentTOP = CellI[3]
ExtentLeft = CellI[0]
TOP = "TOP : " + str(ExtentTOP)
LEFT = "Left : " + str(ExtentLeft)
ExtentRight = ExtentLeft + (RasterColumCount * pixelSizeY)
RIGHT = "Right : " + str(ExtentRight)
ExtentBottom = ExtentTOP - (RasterRowCount * pixelSizeX)
BOTTOM = "Bottom : " + str(ExtentBottom)
with open(filename + 'OrthoMeta.txt', "a") as f:
f.write( Projection+" "+XCol+" "+YRow+" "+Band+" "+pixelX+" "+pixelY+" "+TOP+" "+LEFT + RIGHT + BOTTOM + '\n' )
[SEQUELIZE0004] DeprecationWarning: A boolean value was passed to options.operatorsAliases. This is a no-op with v5 and should be removed (0) | 2020.12.22 |
---|---|
IntelliJ node's module 추가 설치하기 (0) | 2020.03.12 |
동영상 metadata 추출 하는 python source (0) | 2019.11.29 |
Tiff 파일에서 metadata 읽어오기 (0) | 2019.11.29 |
LoopBack mysql 연결설정하기 (0) | 2019.04.08 |