Using GDAL, how can I simply create an empty single band raster? I can't seem to find out how. I know in PostGIS you can create a new table with a 'raster' column type, then insert a band into it. However I'm looking for a slick, GDAL solution (or another efficient non-PostGIS solution).
What I'm looking to create is a raster (GeoTIFF) with these settings:
format: -of GTiff
type: -ot UInt16 (16 bit unsigned integer)
cell resolution: -tr 5 5 (5x5m)
nodata: -a_nodata 255 (the values I intend to burn into this raster range from 1 to 10)
SRID: 27700
extent: -te 0 0 680000 1240000 (rectangular extent of Great Britain)
resulting raster would contain almost 34 billion cells (at 5x5m cell size)!
Best Answer
Since version 3.2, gdal offers
gdal_create
command for this purpose. Just simply use the following:I assumed by the extent, you meant the width and height of the image. For the cell resolution of 5m or whatever else, just set up your georeferenced bounds of the output file based on the image size and the pixel resolution. Add this option to the command line:
-a_ullr <ulx> <uly> <lrx> <lry>
I also added the compression option of
-co COMPRESS=LZW
to be able to save disk space for this huge empty file! However, it did not work! It seems to be a bug for such a big image size. The compression works for smaller image size.Also note the
-burn
value has been set to0
. You can change it to whatever value you like. It takes a while for the image to be created; my write speed was 0.4 MB/s so it took around 2 hours and 6 minutes and the file size was ~2.5 GB. Be patient!Source: https://gdal.org/programs/gdal_create.html