# Digital elevation model
**by [Martin Bently](https://github.com/mtb-za)**
Digital elevation models are two-dimensional rasters. That is, they have elevation values relative to some base level (usually sea level) at each x and y position. The x, y positions form a regular grid. You will receive a grid as a sequence of rows separated by newline characters; each row is a sequence of numbers separated by spaces.
The coordinate of the data point in the lower-left corner is (1000, 1000). The samples are spaced at 100 m intervals in both directions. So the upper-right corner of a 5-cell by 5-cell map has coordinates of (1000, 1400).
You need to answer four questions about your DEM:
1. What is the elevation difference between the highest and lowest points on the DEM?
2. What is the y-coordinate of the highest point?
3. What is the elevation of the highest valley on an east-west line through the highest elevation, **H**?
4. Assume everything below the surface is rock. What volume of rock is strictly greater than the elevation H?
Do not interpolate the data to arrive at your answers. When looking for valleys on a transect, consider any point lower than its neighbours to be a valley, but do not count the end-points of the transect, at the edges of the map. When calculating the volume, assume discrete 3D cells of dimensions 100 m × 100 m × 1 m (this is a coarse, first-order approximation).
## Example
Here's a small example DEM:
14 18 7 5 19 16 13 13
11 7 3 10 14 12 12 17
-1 1 8 14 7 7 9 10
4 8 16 11 12 7 4 11
20 15 18 17 21 13 7 15
20 12 14 15 19 9 9 8
19 11 9 6 10 8 7 5
14 12 2 11 14 17 11 14
We'd answer the questions as follows:
1. The difference in elevation is 21 - (-1) = **22** metres.
2. The index of the row with the maximum elevation has y-coordinate **1300** metres.
3. The row with the maximum elevation has 3 valleys; the highest has elevation **17** metres.
4. The volume contained between the surface and 17 m elevation is **180000** cubic metres.
## A quick reminder how this works
This document is formatted in [Markdown](https://daringfireball.net/projects/markdown/).
You can retrieve your data, which is always a string, by choosing a **``** (also a string). This ensures that you have different data from other people, so be creative.
```
url = 'https://kata.geosci.ai/challenge/dem'
params = {
'key': # Replace with your own string.
}
r = requests.get(url, params)
r.text
```
To answer question 1, change the `params`:
```
params = {
'key': , # Use the same key you used to get your input.
'question': 1,
'answer': 1234 # Your answer; can be a float, int, list or array;
# the challenge description will tell you which.
}
```
To get a hint for a question, provide the question number but no answer:
```
params = {
'question': 1,
}
```
[Complete instructions at kata.geosci.ai](https://kata.geosci.ai/challenge)
[An example notebook to get you started](https://gist.github.com/kwinkunks/50f11dac6ab7ff8c3e6c7b34536501a2)
----
© 2023 [Scienxlab](https://scienxlab.org/) — Code: openly licensed under [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0) — Text: openly licensed under [CC BY](https://creativecommons.org/licenses/by/4.0/).