Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Band 1 Block=64x64 Type=UInt16, ColorInterp=Undefined
- Description = AVHRR Channel 1: 0.58 micrometers -- 0.68 micrometers
- Min=0.000 Max=814.000
- Minimum=0.000, Maximum=814.000, Mean=113.177, StdDev=152.897
- Metadata:
- LAYER_TYPE=athematic
- STATISTICS_MAXIMUM=814
- STATISTICS_MEAN=113.17657236931
- STATISTICS_MINIMUM=0
- STATISTICS_STDDEV=152.89720574652
- #!/bin/sh
- # Image to modify
- IMAGE_PATH='11skd505395.tif'
- # Field to modify
- IMAGE_FIELD='TIFFTAG_IMAGEDESCRIPTION'
- # Print the tiff image description tag
- gdalinfo $IMAGE_PATH | grep $IMAGE_FIELD
- # Change the Field
- CMD="gdal_edit.py -mo ${IMAGE_FIELD}='Lake-Tahoe' $IMAGE_PATH"
- echo $CMD
- $CMD
- # Print the new field value
- gdalinfo $IMAGE_PATH | grep $IMAGE_FIELD
- $ ./gdal-script.py
- TIFFTAG_IMAGEDESCRIPTION=OrthoVista
- gdal_edit.py -mo TIFFTAG_IMAGEDESCRIPTION='Lake-Tahoe' 11skd505395.tif
- TIFFTAG_IMAGEDESCRIPTION='Lake-Tahoe'
- from osgeo import gdal, osr
- import numpy
- # Define output image name, size and projection info:
- OutputImage = 'test.tif'
- SizeX = 20
- SizeY = 20
- CellSize = 1
- X_Min = 563220.0
- Y_Max = 699110.0
- N_Bands = 10
- srs = osr.SpatialReference()
- srs.ImportFromEPSG(2157)
- srs = srs.ExportToWkt()
- GeoTransform = (X_Min, CellSize, 0, Y_Max, 0, -CellSize)
- # Create the output image:
- Driver = gdal.GetDriverByName('GTiff')
- Raster = Driver.Create(OutputImage, SizeX, SizeY, N_Bands, 2) # Datatype = 2 same as gdal.GDT_UInt16
- Raster.SetProjection(srs)
- Raster.SetGeoTransform(GeoTransform)
- # Iterate over each band
- for band in range(N_Bands):
- BandNumber = band + 1
- BandName = 'SomeBandName '+ str(BandNumber).zfill(3)
- RasterBand = Raster.GetRasterBand(BandNumber)
- RasterBand.SetNoDataValue(0)
- RasterBand.SetDescription(BandName) # This sets the band name!
- RasterBand.WriteArray(numpy.ones((SizeX, SizeY)))
- # close the output image
- Raster = None
- print("Done.")
Add Comment
Please, Sign In to add comment