# Ensuring a raster hazard is sampled

**URL:** <https://community.riskscape.org.nz/t/ensuring-a-raster-hazard-is-sampled/107>\
**Category:** Community\
**Created:** [9 November 2022 20:54 UTC](https://community.riskscape.org.nz/t/ensuring-a-raster-hazard-is-sampled/107 "2022-11-09T20:54:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![NickHorspool](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.riskscape.org.nz/nickhorspool/32/53_2.png) [@NickHorspool](https://community.riskscape.org.nz/u/NickHorspool)\
**Post date:** [9 November 2022 20:54 UTC](https://community.riskscape.org.nz/t/ensuring-a-raster-hazard-is-sampled/107/1 "2022-11-09T20:54:17Z")

</div>

I have a hazard layer as a raster (tif) that covers New Zealand. Some areas close to the coastline the raster has no data values due to how the raster was create (based on points on land). I want to ensure that when I sample my exposure layer I get a hazard values for all exposures points. Is there a way to sample the raster using centroid but then if its no\_data then I would find the nearest raster value within a given distance.

---

<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:** [9 November 2022 23:18 UTC](https://community.riskscape.org.nz/t/ensuring-a-raster-hazard-is-sampled/107/2 "2022-11-09T23:18:01Z")

</div>

If the exposures are points, then you can just use ‘closest’ spatial sampling and then specify a buffer distance. In the wizard, the question looks like:

_1: Specify a buffer (i.e. margin of error) when matching exposure-layer elements against the hazards-layer_

In a pipeline, this will look something like: `sample_one(exposure, coverage: hazard, buffer-distance: 5000)`
