赞
踩
def writetiff(outname,data,nl,ns,Lon_Res,Lat_Res,LonMin, LatMax, LonMax, LatMin): # 创建.tif文件 driver = gdal.GetDriverByName("GTiff") out_tif = driver.Create(outname, ns, nl, 1, gdal.GDT_Float32) geotransform = (LonMin, Lon_Res, 0, LatMax, 0, -Lat_Res) out_tif.SetGeoTransform(geotransform) # 获取地理坐标系统信息,用于选取需要的地理坐标系统 srs = osr.SpatialReference() proj_type = 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]' out_tif.SetProjection(proj_type) # 给新建图层赋予投影信息 # 数据写出 out_tif.GetRasterBand(1).WriteArray(data) # 将数据写入内存,此时没有写入硬盘 out_tif.FlushCache() # 将数据写入硬盘 out_tif = None # 注意必须关闭tif文件
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。