-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWriteTiffData_SingleOutput.py
25 lines (24 loc) · 1.05 KB
/
WriteTiffData_SingleOutput.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
def WriteTiffData_SingleOutput(floder_and_filename, ysize, xsize, Array_Content, geotransform, projection):
'''
Writing the array with geographic information.
:param floder_out: directory that you wish to save this output
:param name_out_file: a name for the output, like "Result"
:param ysize: dimension on y
:param xsize: dimension on x
:param Array_Content: the array that you wish to save in the Tiff file
:param geotransform: geotransform information
:param projection: projection information
:return: no return on screen, but an output in the folder
'''
import gdal
import arcpy
driver = gdal.GetDriverByName('GTiff')
print(floder_and_filename)
new_tiff = driver.Create(floder_and_filename, xsize, ysize, 1, gdal.GDT_Float32)
new_tiff.SetGeoTransform(geotransform)
new_tiff.SetProjection(projection)
new_tiff.GetRasterBand(1).WriteArray(Array_Content)
new_tiff.FlushCache() # Saves to disk
new_tiff = None # closes the file
print("Done!!! Tiff data has been written.")
return ()