a guest Mar 23rd, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- # Writing raster dataset
- def write_tif(path_tif, array, geotransform, geoprojection):
- # Checking the dimension of array.
- dim_array = array.shape
- if len(dim_array) > 2:
- depth = dim_array
- depth = 1
- # Initializing TIF dataset driver
- driver = gdal.GetDriverByName("GTiff")
- # Creating actual dataset from TIF drivers.
- outdata = driver.Create(
- path_tif, size, size, depth, gdal.GDT_Float32)
- # sets same geotransform as input
- # sets same projection as input
- # Writing data to array
- for i in range(depth):
- arr = array[:, :, i]
- arr = array[:, :]
- # If you want these values transparent
- # saves to disk!!
- # Releasing memory
- outdata = None
RAW Paste Data