0

I am rasterizing a shapefile of continents. I use the following command:

gdal_rasterize -burn 1  -ts 1440000 560000 -te -180 -60 180 80 -ot Byte -co COMPRESS=PACKBITS -co NUM_THREADS=ALL_CPUS -co BLOCKXSIZE=256 -co BLOCKYSIZE=256 -co PREDICTOR=2 continent.shp continents.tif

You can see I specify the blocksize to be 256 x 256. Yet when I check the blocksize:

blah = gdal.Open(continents.tif)
blah.GetRasterBand(1).GetBlockSize()

Out[74]: [1440000, 256]

gdal_rasterize is overwriting my BLOCKXSIZE specification and instead using the number of columns. Is there any way to force the 256x256 blocksize?

I understand that larger x-blocksizes are more I/O efficient generally, but not for my specific application.

  • 1
    Do you have to force tiling for the TIFF Format with -co "TILED=YES"? – Saleika Sep 12 '17 at 14:48
  • I don't want to tile the raster--I want one TIFF file with 256x256 blocksize. I believe that tiling outputs many smaller individual tiff files. – Jon Sep 12 '17 at 14:51
  • 2
    No, TILED defines how the Bytes are organized inside the TIFF file. It does not outputs smaller individual tiff files. By default stripped TIFF files are created. But you want a tiled TIFF, since you specified the blocksize 256x256 – Saleika Sep 12 '17 at 14:55
  • If you do not set tiled=yes you will get a striped tiff and only blockysize has any effect. Just what you experienced. You do want to get a tiled tiff gdal.org/frmt_gtiff.html. – user30184 Sep 12 '17 at 14:55
  • Ah, OK. The gdal TIFF options says "TILED=YES: By default stripped TIFF files are created. This option can be used to force creation of tiled TIFF files." I assumed that "stripped TIFF files" referred to the same output as gdal_retile. If @Saleika makes an answer I will accept. – Jon Sep 12 '17 at 14:58
2

To force the 256x256 blocksize you have to add the -co "TILED=YES" Option

gdal_rasterize -burn 1  -ts 1440000 560000 -te -180 -60 180 80 -ot Byte -co COMPRESS=PACKBITS -co NUM_THREADS=ALL_CPUS -co "TILED=YES" -co BLOCKXSIZE=256 -co BLOCKYSIZE=256 -co PREDICTOR=2 continent.shp continents.tif

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.