i'm tring to write X array as a new raster, but some thing mistake happen
-- coding: utf-8 --
!/usr/bin/env python
print("Started\n") import gdal import numpy as np
*******************************************************************************
inRaster=r"E:\SEBAL_METRIC_Approaches\ASD\dem.tif" outRaster=r"E:\SEBAL_METRIC_Approaches\ASD\Longdem4.tif" Driver="GTIFF" # HFA Erdas Imagine (.img), GTIFF (TIFF)
*******************************************************************************
inRaster=gdal.Open(inRaster) rows=inRaster.RasterYSize cols=inRaster.RasterXSize dem=inRaster.ReadAsArray() gt=inRaster.GetGeoTransform() pr=inRaster.GetProjection() inBand=inRaster.GetRasterBand(1) (xBlockSize,yBlockSize)=inBand.GetBlockSize() xOrigin=gt[0] pixelWidth=gt[1] yOrigin=gt[3] pixelHeight=gt[5]
X=np.arange(xOrigin,(xOrigin+dem.shape[1]*pixelWidth),pixelWidth) Y=np.arange(yOrigin,(yOrigin+dem.shape[0]*pixelHeight),pixelHeight)
driver=gdal.GetDriverByName(Driver) outRaster=driver.Create(outRaster,cols,rows,1,gdal.GDT_Float32) # the 1 is for band 1 outBand=outRaster.GetRasterBand(1)
NDV = inBand.GetNoDataValue() for i in range(0,rows,yBlockSize): if i+yBlockSize outBand.FlushCache() outBand.SetNoDataValue(NDV) stats=outBand.GetStatistics(0,1) outRaster.SetGeoTransform(gt) outRaster.SetProjection(pr) gdal.SetConfigOption("HFA_USE_RRD","YES") outRaster.BuildOverviews(overviewlist=[2,4,8,16,32,64,128]) print("\nFinished")
أكثر...
-- coding: utf-8 --
!/usr/bin/env python
print("Started\n") import gdal import numpy as np
*******************************************************************************
inRaster=r"E:\SEBAL_METRIC_Approaches\ASD\dem.tif" outRaster=r"E:\SEBAL_METRIC_Approaches\ASD\Longdem4.tif" Driver="GTIFF" # HFA Erdas Imagine (.img), GTIFF (TIFF)
*******************************************************************************
inRaster=gdal.Open(inRaster) rows=inRaster.RasterYSize cols=inRaster.RasterXSize dem=inRaster.ReadAsArray() gt=inRaster.GetGeoTransform() pr=inRaster.GetProjection() inBand=inRaster.GetRasterBand(1) (xBlockSize,yBlockSize)=inBand.GetBlockSize() xOrigin=gt[0] pixelWidth=gt[1] yOrigin=gt[3] pixelHeight=gt[5]
X=np.arange(xOrigin,(xOrigin+dem.shape[1]*pixelWidth),pixelWidth) Y=np.arange(yOrigin,(yOrigin+dem.shape[0]*pixelHeight),pixelHeight)
driver=gdal.GetDriverByName(Driver) outRaster=driver.Create(outRaster,cols,rows,1,gdal.GDT_Float32) # the 1 is for band 1 outBand=outRaster.GetRasterBand(1)
NDV = inBand.GetNoDataValue() for i in range(0,rows,yBlockSize): if i+yBlockSize outBand.FlushCache() outBand.SetNoDataValue(NDV) stats=outBand.GetStatistics(0,1) outRaster.SetGeoTransform(gt) outRaster.SetProjection(pr) gdal.SetConfigOption("HFA_USE_RRD","YES") outRaster.BuildOverviews(overviewlist=[2,4,8,16,32,64,128]) print("\nFinished")
أكثر...