Quantcast
Channel: Question and Answer » gdal
Viewing all articles
Browse latest Browse all 397

specifying extent in GDAL's WriteArray

$
0
0

Is it possible to specify the extent when creating an empty raster in GDAL? I looked everywhere, but can’t seem to find anything. The portion of my script where I write the raster would look something like this:

tifpath = "path/to/output/tiff.tif"
drvtif = gdal.GetDriverByName("GTiff")
rast = drvtif.Create(tifpath, Ncolumns, Nrows, Nbands, datatype)
rast.SetProjection(projection) # projection being a variable representing the desired projection
rast.GetRasterBand(1).WriteArray(array)

My array is an array of size Ncolumns x Nrows, filled with 0′s (I want an empty raster). The number of pixels is predetermined, as is the cell size, and by multiplying npixels*cellsize, I’ve determined what my output extents need to be such that each pixel is a whole pixel (i.e. doesn’t get cut off by the extent).

But, I can’t find any options that would allow me to specify the desired extent. Suggestions?

EDIT: It’s also just occurred to me that I don’t see any option to specify cell size. Am I missing something here?

Thanks


Viewing all articles
Browse latest Browse all 397

Trending Articles