La versión en pseudocódigo:
import gdal
import numpy
create the gdal output file as geotiff
set the no data value
set the geotransform
numpy.genfromtxt('your file', numpy.int8) #looks like int from you example
reshape your array to the shape you need
write out the array.
Una muestra que le ayudará a lo largo - desde aquí :
if __name__ == '__main__':
# Import libs
import numpy, os
from osgeo import osr, gdal
# Set file vars
output_file = "out.tif"
# Create gtif
driver = gdal.GetDriverByName("GTiff")
dst_ds = driver.Create(output_file, 174, 115, 1, gdal.GDT_Byte )
raster = numpy.zeros( (174, 115) )
# top left x, w-e pixel resolution, rotation, top left y, rotation, n-s pixel resolution
dst_ds.SetGeoTransform( [ 14.97, 0.11, 0, -34.54, 0, 0.11 ] )
# set the reference info
srs = osr.SpatialReference()
srs.SetWellKnownGeogCS("WGS84")
dst_ds.SetProjection( srs.ExportToWkt() )
# write the band
dst_ds.GetRasterBand(1).WriteArray(raster)
0 votos
El software GIS puede convertir asci a geotiff. No es necesario codificar. Yo uso QGIS. Es gratuito.