Sunday, 23 October 2016

gdal - How to set opacity with gdal_rasterize


I am using gdal_rasterize to create a raster of a huge file containing polygons. I managed to generate the raster file with the right color and with the minimum size to tile it after with the gdal2tile.


gdal_rasterize -of GTiff -co COMPRESS=DEFLATE 

-b 1 -b 2 -b 3 -burn 136-burn 46 -burn 17
-co PREDICTOR=2
-co ZLEVEL=9
-ot Byte
-a_nodata 255
-a Niveau
-ts 500000 500000
-l layer W:/layer.shp
W:/layer.tif


Tile will be used to overlay Google Maps so the polygon must be transparent.


Has anybody experimented with this usage of gdal_rasterize and succeeded in setting the opacity of the output raster?



Answer



Sorry for the short answer but I suppose that simply adding an alpha channel might do the trick. At least I could make an output that is semi-transparent in QGIS with the following command.


gdal_rasterize -of gtiff
-ot byte
-co alpha=yes
-burn 255 -burn 0 -burn 0 -burn 100
-ts 500 500
-l test test.shp test.tif

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...