Clip a list of geotiff

I have a list of geotiffs that I am loading as my hazard layers

input(relation: 'hazards_10') as hazard_input
# and load the tiff that's in the location column
-> select({
    # flood is a 'template' bookmark - the location is replaced, but everything else stays the same
    bookmark('flood', {location: location}, type: 'coverage(floating)') as coverage
  } as event
}) as hazard_and_coverage -> exposures_join_hazards.rhs

I would like to clip this using a shape file that I have bookmarked

location = Data/Clip.shp

I have seen the tutorial on clipping by shape here but I cannot see how to include that in my loading code

Hi John,

By clip, do you mean you want to reduce the extent of the GeoTIFFs that are coming in? Or do you want to filter out GeoTIFFs that don’t overlap at all with the Clip layer?

If you’re trying to reduce the extent of the GeoTIFFs, then you can’t really do that in RiskScape. However, you could just filter or cut the exposure-layer by the Clip layer, so there are less/smaller exposures to sample against your GeoTIFFs.

If you’re trying to filter out unnecessary GeoTIFFs completely, you could use a filter step that checks if the bounds(coverage) overlaps with the Clip layer. That might look something like:

filter(is_not_null(sample_one(bounds(coverage), to_coverage(bookmark('Clip'))))

Hope that helps.


I have tried adding

framework = pipeline
location = pipeline_Aggregated_Model_0.txt
exposures_input.cut = BY_LAYER
exposures_input.cut-by-layer = Clip
exposures_input.cut-by-layer-include = ALL_PARTS
hazard_input.cut = BY_LAYER
hazard_input.cut-by-layer = Clip
hazard_input.cut-by-layer-include = ALL_PARTS

to my model.ini

but that gives

[WARNING] Problems found with 'RoadSegmentFloodDamage_0_autoclip' identified model
  - Surplus parameters were given that were ignored: [exposures_input.cut-by-layer, hazard_input.cut-by-layer, exposures_input.cut, hazard_input.cut, hazard_input.cut-by-layer-include, exposures_input.cut-by-layer-include], did you mean one of []?

Hi Tim,

I have clipped my asset dataset down to be 2.8km of road but it still takes over 10 minutes to run. My expectation would be that such a small input data set would only take a few seconds to run even though it is being compared to 20 hazard layers.

I am going to manually clip the hazard layers down to the same extent as the asset data set and see if that helps


I doubt that clipping the hazard extent would make any difference. I’m guessing the grid-size in the GeoTIFFs is fairly small here?

A couple of things that might help are:

  • Making sure the exposure-layer is in the same CRS as the hazard-layer. RiskScape will reproject for you, but it’s doing this reprojection for every single hazard-layer, which is inefficient.
  • Potentially cutting your roads into smaller segments. Currently I think it’s checking each grid cell that overlaps with the bounds of the road, and then checks whether the grid cell intersects the line-string itself. It’s in our backlog to make that more efficient.

Hey Tim

The hazards are on a 10x10 metre grid
Everything is in ESPG:2193
Tried setting the road segmenting to 5 metres but this has made it slower