#!C:/Python27/ArcGIS10.1/python.exe -u
#coding:utf-8
'''the first two lines are used to choose the
compiler(python.exe) and set the coding format
user:jinshichao @ chinese academic of science
cmd 命令行脚本下 chcp 936 可打印中文
python raster read,chose, and close
'''
##########读 GeoTiff 文件示例 1
from osgeo import gdal
import numpy as np
import os
os.chdir(r"D:\UCAS_Class\python\chapter_02\chapter_02")
dataset=gdal.Open("fdem.tif") #打开文件
#dir(dataset) 查看哪些方法可以用
im_width = dataset.RasterXSize #栅格矩阵的列数
im_height = dataset.RasterYSize #栅格矩阵的行数
im_bands = dataset.RasterCount #波段数
im_geotrans = dataset.GetGeoTransform()
#仿射矩阵,左上角像素的大地坐标和像素分辨率(左上角x, x分辨率,仿射变换,左上角y坐标,y分辨率,仿射变换)
im_proj = data