# Clip a list of geotiff

**URL:** <https://community.riskscape.org.nz/t/clip-a-list-of-geotiff/161>\
**Category:** Community\
**Created:** [5 March 2024 21:56 UTC](https://community.riskscape.org.nz/t/clip-a-list-of-geotiff/161 "2024-03-05T21:56:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JPowell](https://avatars.discourse-cdn.com/v4/letter/j/bbce88/32.png) [@JPowell](https://community.riskscape.org.nz/u/JPowell)\
**Post date:** [5 March 2024 21:56 UTC](https://community.riskscape.org.nz/t/clip-a-list-of-geotiff/161/1 "2024-03-05T21:56:45Z")

</div>

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

```auto
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

```auto
[Clip]
location = Data/Clip.shp

```

I have seen the tutorial on clipping by shape here [https://riskscape.org.nz/docs/intermediate/geoprocessing.html](https://riskscape.org.nz/docs/intermediate/geoprocessing.html) but I cannot see how to include that in my loading code

---

<div class="post-metadata">

**Author:** ![timbeale](https://avatars.discourse-cdn.com/v4/letter/t/57b2e6/32.png) [@timbeale](https://community.riskscape.org.nz/u/timbeale)\
**Post date:** [5 March 2024 22:07 UTC](https://community.riskscape.org.nz/t/clip-a-list-of-geotiff/161/2 "2024-03-05T22:07:18Z")

</div>

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:

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

```

Hope that helps.

Tim

---

<div class="post-metadata">

**Author:** ![JPowell](https://avatars.discourse-cdn.com/v4/letter/j/bbce88/32.png) [@JPowell](https://community.riskscape.org.nz/u/JPowell)\
**Post date:** [5 March 2024 22:07 UTC](https://community.riskscape.org.nz/t/clip-a-list-of-geotiff/161/3 "2024-03-05T22:07:29Z")

</div>

I have tried adding

```auto
[RoadSegmentFloodDamage_0_autoclip]
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

```auto
[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 []?

```

---

<div class="post-metadata">

**Author:** ![JPowell](https://avatars.discourse-cdn.com/v4/letter/j/bbce88/32.png) [@JPowell](https://community.riskscape.org.nz/u/JPowell)\
**Post date:** [5 March 2024 23:19 UTC](https://community.riskscape.org.nz/t/clip-a-list-of-geotiff/161/4 "2024-03-05T23:19:08Z")

</div>

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

Thanks  
John

---

<div class="post-metadata">

**Author:** ![timbeale](https://avatars.discourse-cdn.com/v4/letter/t/57b2e6/32.png) [@timbeale](https://community.riskscape.org.nz/u/timbeale)\
**Post date:** [6 March 2024 00:00 UTC](https://community.riskscape.org.nz/t/clip-a-list-of-geotiff/161/5 "2024-03-06T00:00:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JPowell](https://avatars.discourse-cdn.com/v4/letter/j/bbce88/32.png) [@JPowell](https://community.riskscape.org.nz/u/JPowell)\
**Post date:** [6 March 2024 00:46 UTC](https://community.riskscape.org.nz/t/clip-a-list-of-geotiff/161/6 "2024-03-06T00:46:34Z")

</div>

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

Cheers  
John
