# How to approximate the elevation of a shapefile in any pixel of a grid using a digital terrain model?

Introduction
I am working on some flood maps of a given region. As the data is confidential, I will try to stay as general as possible without any loss of relevant information. The truth is, my knowledge on GIS is limited.

Available databases / files for my analysis
Some data on a river and its bank:

1. A precise digital terrain model (.adf / ArcInfo binary grid format). The pixel size is 1m x 1m.
2. a polygon (one feature in an ESRI shapefile). This polygon contains the 2D information on the flood boundary (it delimits where a river will overflow). No altitude or Z elevation is contained in this file.

Even though that information is not contained in the polygon, the elevation at each point on the boundary polygon is basically the same.

The problem I am facing

I would like to deduce the flood depth (the water height) observed in each cell of a grid (of the same resolution as the DTM). And then map it.

I am assuming this would be simple if we had the information on the elevation of the data contained in the shapefile. In this case, I would convert that shapefile to a raster and do a little subtraction. But I do not have it and I must deduce it.

I am comfortable with any coherent approximation. I must know this information at any pixel inside the polygon, not just on its boundary.

The tools I would like to use
I exclusively work with QGIS (in its latest version - Las Palmas). I do not have an ArcGIS licence.

• First thing to check would be consistency of the data. Is the elevation at each point on the boundary polygon basically the same? How do you want to map the elevation (flood depth)? That is, what kind of rendering do you want? – BradHards Sep 20 '17 at 7:19
• It should normally be the same. These polygons are generated using an hydraulic simulator (HEC-RAS). These physical simulations gives us one polygon with a unique elevation. So each point of its boundary should have the same height. Honestly, for the rendering, I would be fine with just the numerical values of the flood depth (in each pixel), but it would be nice to have some kind of color code for the rendering. Does that answer your question? Thank you very much! – J-M Potvin Sep 20 '17 at 13:01
• It should be the same, but is it? Does it match your DEM? Rendering (however you do it) will give you bogus results if you don't match the source data sets first. I'd suggest putting that detail in the question (just click edit below the question. – BradHards Sep 20 '17 at 22:14
• It is. It maches my DEM (I verified that information). That information is now part of the initial question. Thanks! – J-M Potvin Sep 27 '17 at 15:46

I found a working solution using solely QGIS.

Hypothesis: if you assume that the elevation is stable, that is:

1. local variations of altitude/z-elevation are permitted but
2. the overall terrain model must not be inclined. There must be no systematic loss of elevation in the natural direction of the river flow.

Then, the final solution was quite simple:

1. Clip the terrain model using the polygon as a mask layer. This can be done easily by using the Clipper toolbox ( Raster - Extraction - Clipper). If the polygon has a complex shape / boundary, you may want to simplify the geometry first, by using the Douglas-Peucker algorithm implemented in the Simplify geometries toolbox of QGIS (Vector - Geometry tools - Simplify geometries).
2. Calculate the maximum elevation of the clipped terrain model (check either the properties of the clipped raster or use the Raster calculator toolbox).
3. Perform a mathematical operation on the clipped raster. Calculate the observed difference between the maximum value of the clipped raster and the terrain model.

By doing this, you will obtain a grid of water heights. Each cell will have its own value. Outside the polygon, those heights will be equal to 0 (no flood has occurred). The rendering can be adjusted by modifying the style of the grid / raster obtained at step 3.

For the step 1, I chose the GeoTIFF format for my output.
{"ft_lang_label":"__label__en","ft_lang_prob":0.9229927,"math_prob":0.875308,"size":1427,"snap":"2019-51-2020-05","text_gpt3_token_len":319,"char_repetition_ratio":0.116654955,"word_repetition_ratio":0.0,"special_character_ratio":0.21723896,"punctuation_ratio":0.08741259,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9644685,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-01-29T01:07:19Z\",\"WARC-Record-ID\":\"<urn:uuid:8dd27271-1282-4c32-b184-f9db06f82740>\",\"Content-Length\":\"137500\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:ee21fc9e-5b86-43d2-84b7-5ba0a61681aa>\",\"WARC-Concurrent-To\":\"<urn:uuid:f38639e7-2751-4ccd-a65a-294df45d395f>\",\"WARC-IP-Address\":\"151.101.1.69\",\"WARC-Target-URI\":\"https://gis.stackexchange.com/questions/255969/how-to-approximate-the-elevation-of-a-shapefile-in-any-pixel-of-a-grid-using-a-d\",\"WARC-Payload-Digest\":\"sha1:SZKAXDKOQG6OZIP5WXTGDZH6NSCIKQPQ\",\"WARC-Block-Digest\":\"sha1:FDACCK5GXZHIZW3JDOYE4XATLBIXL7IY\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-05/CC-MAIN-2020-05_segments_1579251783621.89_warc_CC-MAIN-20200129010251-20200129040251-00279.warc.gz\"}"}