Package: nevis
Where is Ben Nevis?"Where is Ben Nevis" is a fun(?) project which presents the landscape of Great Britain (GB) as a testbed for numerical optimisation and sampling methods.
Its main component is a Python module calledneviswhich can download height data from the Ordnance Survey, process it to make it more suitable for optimisation, and provide interpolating functions so that it can be treated as a continuous (but not smooth) real-valued function.InstallationPython 3.6 or newer is required.To install from thePython Package Index (PyPI), use:pip install nevisTo install the optionalconvertbngmodule at the same time, use:pip install nevis[extras]This will make conversion from points in the data set to longitude and lattitude more accurate.Developers may wish to skip PyPI installation, clone theGitHub repository, and install from there instead.
Instructions for this are provided inCONTRIBUTING.md.After installing the module, the "OS Terrain 50" data set needs to be downloaded from from the Ordnance Survey website (see the "Data set" section below).
This can be achieved using:import nevis
nevis.download_os_terrain_50()By default, the heights data is installed into~/nevis-data.
For example/home/michael/nevis-dataon a Linux system orC:\Users\michael\nevis-dataon Windows.
This installation path can be changed by specifying an alternative directory in the environment variableNEVIS_PATHbefore runningdownload_os_terrain_50().Note that OS Terrain 50 is not part ofnevisor "Where is Ben Nevis" and comes with its own license.
SeeLICENSE.mdfor details.To check that the installation was succesfull, you can plot a height map of GB:# Import nevis
import nevis

# Download the data (you can skip this step after the first run!)
nevis.download_os_terrain_50()

# Create and store a figure
nevis.write_test_figure('gb-small.png')This should create a file (in your working directory) calledgb-small.png:UsageDetailed usage examples will eventually be provided in theexamplesdirectory.
For the time being, please seefit.pyfor an example.An example of its output is given below:|>          
 Starting Ben   |   Nevis   
               / \    Local
            /\/---\     0.0.4
           /---    \/\      
        /\/   /\   /  \     
     /\/  \  /  \_/    \    
    /      \/           \   
Minimising error measure
Using Covariance Matrix Adaptation Evolution Strategy (CMA-ES)
Running in sequential mode.
Population size: 100
Iter. Eval.  Best      Current   Time m:s
0     100    -424.4599 -424.4599   0:00.1
1     200    -609.9036 -609.9036   0:00.1
2     300    -609.9036 -555.6289   0:00.2
3     400    -759.5307 -759.5307   0:00.2
20    2100   -951.8221 -740.9721   0:00.4
40    4100   -1268.672 -1257.865   0:00.7
60    6100   -1308.976 -1308.976   0:01.0
80    8100   -1309.1   -1309.1     0:01.3
100   10100  -1309.1   -1309.1     0:01.6
120   12100  -1309.1   -1309.1     0:01.9
140   14100  -1309.1   -1309.1     0:02.1
160   16100  -1309.1   -1309.1     0:02.2
168   16800  -1309.1   -1309.1     0:02.3
Halting: No significant change for 100 iterations.

Saving figure to results/local-map-full.png.
Saving figure to results/local-map-zoom.png.
Saving figure to results/local-line-plot.png.

Congratulations!
You landed at an altitude of 1309m.
  https://opentopomap.org/#marker=15/57.07019/-3.669487
You are 31m from the nearest named hill top, "Ben Macdui",
  ranked the 2d heighest in GB.
  http://hillsummits.org.uk/htm_summit/518.htmAPI DocumentationFull API documentation is provided athttps://nevis.readthedocs.io.Data setHeight information is from theOS Terrain 50data set made available by the UK's Ordnance Survey.The data is divided into squares indicated with a two letter code, and several data files per square.
Each data file, however, contains its absolute "eastings" and "northings" and so we can ignore the letter codes.
Eastings and northings are defined by the "National Grid", orOSGB36.
In easier terms, they are x and y coordinates, in meters, relative to the bottom-left point of the grid (which is the bottom left of the square "SV", which contains the Isles of Scilly).As an example, the header from the NN17 file is:ncols 200
nrows 200
xllcorner 210000
yllcorner 770000
cellsize 50Herencolsandnrowsindicate the number of grid points in the file, the Lower Left corner of the data in the file is given byxllcornerandyllcorner, and the distance between any two data points is given ascellsize.
In the OS Terrain 50 data set, the cellsize is always 50 (giving it its name).
There is a more accurate OS Terrain 5 set that costs money.According toWikipedia, the approximate coordinates for Ben Nevis are 216600, 771200 (which is in the NN17 square).An easy way to find places on the grid is withhttps://britishnationalgrid.uk.
Another nice map with BNG coordinates ishttps://explore.osmaps.com.
A a great map without BNG coordinates can be found athttps://opentopomap.org.The seaThe sea is a bit messy in these files, as the values depend on mean sea level in each 10x10 km^2 area (OS Tile) relative to OS datum (0m) levelwhich is mean sea level in Newlyn, Cornwall.Hill topsNames of hill and mountain tops are taken fromThe Database of British and Irish Hills v17.2, which is made available under a CC-BY license.
A greatly reduced list, based on this database, is included innevis.
Please seeLICENSE.mdfor the licensing information.Lattitude and longitude 🐇🕳️What about longitude (east-west) and lattitude (north-south)?
These are defined, it seems, byWGS 84, although there is a Europe-specific version called ETRS89 which "for most purposes ... can be considered equivalent to WGS84" ("Transformations and OSGM15 User Guide").
Transforming from national grid coordinates to longitude and lattitude is hard, and the Ordnance Survey have released a thing calledOSTN15to do this.
Although this still seems to result in x, y coordinates, not degrees.
Luckily, somebody'smade a tool for it.
Unfortunately, some people have issues installing this, so that we rely on aless accurate fallbackfor the time being.
If you can, please manually installconvertbngtoo (BenNevis will try using this first, before switching tobnglonglat).InterpolationTo get heights for arbitrary points, we need to interpolate.
By default, we use a linear interpolant.
We also experimented with a scipyRectBiVariateSpline.
This takes some time (~30 seconds on a fast machine) and uses considerable memory (~3GB).
Most importantly, the spline shows some very serious (and unrealistic) artefacts near high gradients (e.g. at the sea side), so that the linear interpolation seems the way to go for now.