[Qgis-user] Raster dynamic clipping mask

Andreas Neumann a.neumann at carto.net
Tue Jun 27 12:00:47 PDT 2017


Hi Olivier,

Geotiff allows to have an alpha channel. You can create an alpha channel 
from a vector layer, using gdalwarp.

Here is one of the commands I use:

gdalwarp -of GTiff --config GDAL_TIFF_INTERNAL_MASK YES -wm 500 --config 
GDAL_CACHEMAX 500 -multi -wo NUM_THREADS=4 -wo OPTIMIZE_SIZE=TRUE 
-cutline dop2016_lv95_cutline.gpkg -crop_to_cutline -dstalpha -co 
"BIGTIFF=YES" -co "TILED=YES" -co "COMPRESS=JPEG" -co "JPEG_QUALITY=85" 
-co "PHOTOMETRIC=RGB" -co "SPARSE_OK=TRUE" dop2016_lv95_tmp.tif 
dop2016_lv95.tif

note the parameters "-cutline vectorfile" -crop_to_cutline and -dstalpha

I know, it is not as easy and straight-forward as you may want it to be, 
but it works. And of course it is not dynamic.

Andreas

On 27.06.2017 18:26, Olivier Dalang wrote:
> Dear List,
>
> I was wondering whether there is an easy solution to have dynamic 
> clipping masks for rasters, just like vector masks in Photoshop (or 
> similar software) ?
>
> For now, I was using a layer with the inverted polygon renderer to 
> hide with a white layer everything that is outside of the polygon. 
> This works great, but then it's not possible to show anything behind 
> the raster.
>
> I know it's easy to statically clip a raster, but this is not usable 
> when working with some rasters types (eg. xyz tiles). Also it's not 
> optimal, as the hidden area is still rendered. And it requires to 
> write a copy of the layer, which can be slow and/or use a lot of disk 
> space.
>
> Thanks !!
>
> Olivier
>
>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20170627/b059a1fc/attachment.html>


More information about the Qgis-user mailing list