[gdal-dev] saving numpy array as ascii raster
Bryan Keith
bryan at ideotrope.org
Thu Mar 5 15:28:09 EST 2009
> Hello Again,
> def WriteRaster (dst_filename, raster):
>
> format = "GTiff"
Oz,
You're creating a geotiff. Try:
format = "AAIGrid"
> driver = gdal.GetDriverByName( format )
> dst_ds = driver.Create( dst_filename, 71, 73,\
> 1,gdal.GDT_Float32,options=["COMPRESS=PACKBITS","TFW=YES"]
> )
These options won't be available for "AAIGrid".
> dst_ds.SetGeoTransform( [-19.5, 1.0, 0.0, 37.5, 0.0, -1.0] )
> srs = osr.SpatialReference()
> srs.ImportFromEPSG(4326) #WGS84 lat long.
> dst_ds.SetProjection( srs.ExportToWkt() )
> dst_ds.GetRasterBand(1).WriteArray( raster )
> dst_ds = None
>
>
> c= a+b
> print c
> WriteRaster ('raster3.gtiff', c)
>
> A file with following content is created:
>
> 1.0000000000
> 0.0000000000
> 0.0000000000
> -1.0000000000
> -19.0000000000
> 37.0000000000
This file must be the .tfw, right? I expect you created a geotiff file as
well which is where your data is.
Bryan
More information about the gdal-dev
mailing list