Clip a raster by building polygon
Runnable Spatial Hop raster tutorial with sample data and actual Hop screenshots.
All raster tutorials · Vector Raster plugin
Create one masked GeoTIFF for each of the 33 building footprints. No other land-cover categories are processed.
Before you begin
Set up the complete raster project. Tested on 3 October 2026, Apache Hop 2.19.0, Java 21.0.10, with the plugin builds recorded in the ZIP’s tested-environment.json. Use the local run configuration.
Complete project ZIP. Individual pipelines need the data and metadata from that ZIP.
Read buildings and create unique paths
- Open
clip-polygon.hpl. Read buildings readsdata/buildings.gpkg, layerbuildings, geometry fieldgeometrie. - Buildings only additionally checks
art_txt = Gebaeude. Its false branch explicitly discards other rows. - Build output path creates
${PROJECT_HOME}/output/building-<building_id>.tif.building_idis the original source primary key exposed as a regular attribute. - Read nDSM adds the same local raster source to every building row.
Configure Clip and Writer
| Setting | Value |
|---|---|
| Clip input raster / output raster | raster / empty (replace) |
| Clip method | POLYGON |
| Geometry field / explicit CRS | geometrie / EPSG:2056 |
| Bands / NoData override | ALL / empty |
| Writer output mode / field | Input field / output_path |
| Format / compression | GEOTIFF / Deflate |
| Overwrite | Off |

Run and check
Expect 33 TIFFs, each in EPSG:2056 on the original 0.25-metre grid. The rectangular file extent encloses the building; cells outside its polygon are masked as NoData. Source values inside the mask remain unchanged. Buildings without valid source pixels still produce a masked raster with no valid height samples.

Things to watch out for
- A fixed output filename would collide across rows. Use the
output_pathfield and keep one Writer copy. - Polygon masking and the raster’s rectangular bounds are different: an output TIFF is not a polygon-shaped file.
- Polygon holes stay masked; invalid geometries must be repaired upstream.
- NoData does not mean zero metres. A zero sample remains valid.
- To repeat the complete example, remove only the generated
building-*.tiffiles or choose a fresh output directory.
