In which you apply the skills that you have learned across the whole course to slip across the medieval Welsh border without being seen
NOTE: only postgraduates should complete this assessment!
Introduction
For much of the medieval period, the Welsh Marches (the borderland between England and Wales) was one of the most heavily fortified landscapes in Europe. Castles, mottes, towers and other fortifications were built by both sides and control of the area changed hands many times. Anyone travelling through it would therefore have been watched from a great many vantage points. In such a contested landscape, however, a traveller might reasonably prefer that nobody saw them at all. Spies or messengers crossing the border, for example, would have sought routes in which the risk of being spotted would be minimised.
If only they had studied Understanding GIS…
The Question
Write a Python script to determine the extent to which it might have been possible to travel on foot from Welshpool to Shrewsbury without being seen by lookouts posted on fortifications by either party and how much longer it would have taken than the direct route.
Produce a 1,000 word report that explains and justifies your approach, and discusses the trade-off between speed and concealment.
The analysis and outputs should be completed entirely in Python using only the libraries provided in the
understandinggisenvironment and the report should include at least one map. You must submit both your code and report successfully for the submission to be valid.Make sure that you read this whole document before you start!
What you need to produce
-
A Python script that calculates a range of fastest and least visible walking routes from Welshpool to Shrewsbury.
-
A report including:
- At least one map (plotted in your Python script), showing routes and the areas that are visible to the lookouts.
- A table comparing at least three different routes to facilitate discussion relating to the tradeoff between speed and stealth.
Note that there is no single ‘correct’ least visible route - it depends upon decisions that you make about how visibility should be penalised. What matters is that those decisions are sensible, clearly explained and justified.
Contents
- Data & Approach
- Submission
- Marking Criteria
- Word Count
- AI Usage (AI Prohibited)
- Assessment 2 Hints & Tips
Data & Approach
Data
The datasets for this assessment are available in the data/welsh-borders/ directory in the repository:
data/welsh-borders/welsh_border.vrt: a 50m resolution DEM of the area, taken from OS Terrain 50. This is a Virtual Raster (VRT) that stitches together the 15 OS Terrain 50 tiles (also in the directory) ‘on the fly’ into a single dataset covering 50km x 30km. You can open it withrasteriojust like any other raster dataset.data/welsh-borders/marches_sites.csv: the locations of the 142 medieval fortified sites (castles, mottes, ringworks, towers, town defences and so on) that fall within the area covered by the DEM. Each row contains the name of a site and its easting and northing (British National Grid).
All coordinates are in the British National Grid (EPSG:27700), which is the same CRS as the DEM. The start and end of your route are:
| Location | Easting | Northing |
|---|---|---|
| Welshpool (start) | 322500 | 307500 |
| Shrewsbury (end) | 349200 | 312500 |
You should assume that each fortified site had a lookout positioned with their eye-line 5m above the ground. This and a number of other parameters are included in the code template to get you started, but you may change them if you wish.
You are welcome to include any additional data that you like in order to embellish the analytical or cartographic quality of your report (just make sure to add it to your repository).
Approach
You already know how to implement a viewshed algorithm from Understanding Surfaces II, and that should work for you almost without modification. Your goal here is to calculate a cumulative viewshed for the 142 fortifications in the study area. The result of this will be a raster showing how many fortifications can see any given location. An example of a cumulative viewshed created as part of some work I did on a similar topic in 2017 is here:

You already know how to implement the A* algorithm Hart et al. (1968) from Understanding Networks, but there are three key differences between that version and the one you need to make here:
- You need to convert it to work with a raster rather than a network dataset. This is relatively simple, because in a raster implementation, every cell is just connected to its 8 neighbours (and you know how to find them from Understanding Surfaces I).
-
You are not dealing with the shortest route (distance), but rather the fastest route (time). Time is calculated using Tobler’s Hiking Function Tobler, 1993, which is a simple equation that converts a given distance and slope into a travel time. I have already included this function in the code template for you, but for completeness, the equation is here ( \(W\) is walking speed in km/h), \(S\) is the slope of the ground, and $$ x \(means the absolute number of\)x$$):
- You are not just optimising on a single variable (distance), but balancing two: time and visibility. This is achieved using a simple weight function like this:\(S\)
# calculate the score for a cell
score = time * (1 + weight * visibility)
A weight of 0 just gives the fastest route, and increasing weights give increasing importance to visibility. I have put a set of example weights in the code template of 0, 1, 2, 5 and 10, but feel free to edit them as you see fit.
Submission
This work must be submitted by 14:00 on Thursday 14th January 2027.
You must submit your code and a report of up to up to 1,000 words in length describing the choices that you made in order to create an accurate and efficient algorithm. Code snippets can be used in the report where appropriate (not included in the word count) - but remember that I do not want a line by line description of your code (that is what your comments are for)!
***Note that you must submit your assessment as described here - not having read the below instructions will not be accepted as a reason for late or incorrect submission***
-
The Code part of your submission must be submitted as a link to your Assessment 2 GitHub Repository (see below), stored under your using your
gis-123456789GitHub account. Submit the HTTPS URL to this formThe URL is easily accessed by going to your
ugis-assessment2repository on the GitHub website, clicking the the green Code button and selecting the HTTPS tab. It should look something like this:https://github.com/gis-123456789/ugis-assessment2.git).Please make sure you submit your own link - not my
jonny-hucklink or the123456789example above!
-
The Report part of your submission must be submitted as usual on Canvas. The report should contain the map(s) and table(s) that you have produced. Submitted files should be named in the format:
123456789.docxor123456789.pdfetc. -
Please check that my user has been successfully added to your GitHub repository (in Collaborators on the website) - if it still says “pending invite” at the time you submit, then please delete the invite and re-send.
Creating your Assessment 2 Git Repository
Your Assessment 2 Git Repository should be separate to your main understandinggis repository. Do not attempt to store it inside your existing repository! As before, you will create this using a template that already contains the necessary directory structure and datasets. This is just the same process as you did in Week 1, and for Assessment 1:
First, go to this website to get the Assessment 2 template. Click on the green Use this template button in the top right and select the option for Create a new repository. Name the repository ugis-assessment2, set visibility to Private and click the green Create Repository button. Follow the process until you have your repository.
Next, click on Settings (at the top of the page) → Collaborators and click Add people.
Type jonny-huck into the search bar and select my user “Jonny Huck” (NOTE: you need to add jonny-huck, not jonnyhuck), then click Invite - this will allow me to be able to access the repository for marking purposes.
Finally, clone the repository into your UGIS/ directory using GitHub Desktop.
You are now ready to start coding your assessment! Don’t forget to commit regularly with informative messages and push to your remote repository (this is what gets marked, and also provides a backup of your code in case of disaster!).
Marking Criteria
Marks will be given based upon:
- The quality of the solution (code repository) (60%), comprising:
-
Adherence to the AI Policy
-
Evidence of proper use of version control (frequent commits and informative messages, assessed through the
git log). The assessment of your version control then serves as a multiplier (on a scale of 0-1) for:- Detailed comments (remember the rule of thirds), demonstrating a thorough understanding of what you have done - assessed by reading the code - this is the most important part
- The presentation and elegance of the code - assessed by reading the code
- The result (i.e., does the solution give sensible routes that are consistent with your stated approach) - assessed by running the code
- The efficiency of the solution (i.e., the speed with which your algorithm resolves the problem) - assessed by running the code
- The robustness of the solution (i.e., the script will not fail if it encounters ’normal’ problems, such as incorrect file paths, missing or erroneous data, unexpected inputs, locations that cannot be reached, and so on) - assessed by running the code
Accordingly - please be sure that you understand that inadequate version control will severely limit the marks available to you - it is vitally important that you commit frequently with detailed commit messages and that your code contains detailed comments.
-
The quality of the report (40%), comprising:
-
You should briefly explain your approach, providing a justification for the key decisions that you have made in your implementation (e.g., your visibility parameters, your cost function and heuristic, how you penalised visibility, and whether or not to parallelise your analysis).
This is not a line by line description of your code (your comments do this), but an explanation of why you made key decisions that contributed to the accuracy, elegance, efficiency or robustness of your solution; and the quality of the map.
-
An interpretation of your results: how much longer does the least visible route take, how much less visible is it, and how sensitive is it to the weight that you gave to visibility?
-
A discussion of the key limitations of your analysis, including a clear demonstration of your understanding of the Geographical Information Science involved (e.g., what factors affect the accuracy of a least-cost path or viewshed for this purpose?)
-
If you use functions that are not drawn from the practicals, you must explain them fully to demonstrate understanding and provide references to the associated documentation.
-
The cartographic quality and legibility of the resulting map(s) and table(s).
Note:
- In all of the above, you would expect clear links to the theoretical material that we have covered in class - so think carefully!
- Space is limited, so you need to prioritise the most important elements that best demonstrate your understanding.
- References are not mandatory, but you can include them if you wish to support your demonstration of understanding.
-
The key to this is in the name of the course: In both your code and report I want you to demonstrate a clear understanding of what you have done (this is why comments and commit messages are so important in your code)!
Word Count
The word count for the report is 1,000 words. This includes everything except:
- Code Snippets
- Reference List
Please note that word counts are important. The university applies penalties for being over length as follows (this is true of all of your courses):
- 10-50% over length (1,100 words): the maximum score for the report is capped at 50
- >50% over length (1,500 words): the report is automatically given 0
AI Usage (AI Prohibited)
In accordance with the SEED assessment requirements, this assignment is designated as AI Prohibited, so you should not use AI in the preparation of your code or report. This is in support of helping you develop your understanding, as was explained in the Week 1 Lecture, and in the course AI Policy (you may not use AI to generate code or comments for your Assessment).
Assessment 2 Hints and Tips
Remember the golden rule: Don’t Panic! You have done everything you need to complete this assessment in the course already, this is just a matter of finding the right bits and putting them together! In particular, look back at:
- Understanding Surfaces: moving between coordinate space and image space and finding the neighbours of a cell
- Understanding Surfaces II: calculating a viewshed
- Understanding Networks: the A* algorithm, heuristics and heap queues
As with Assessment 1 - the key is to plan what you are going to do before you start coding - don’t just dive in and hope for the best. All you need to do is keep breaking down each stage into smaller and smaller jobs until you have a clear idea of how the program should look (think about the algorithm, and consider writing out some pseudocode).
Everything that you need to be able to do has been covered in the course before, so if you find yourself heading too far off the beaten track, then this is a good clue that you might be overcomplicating things! Remember that you have generic examples of all of the major operations that we have covered available in the Hints page, and the solutions for all of the previous practicals are available on the Solutions page. If you get stuck, you can get help via the forum!
Please remember that the task is to write your own implementation of the A* and Viewshed algorithms, so do not try and use third part libraries to handle these for you.
Code Presentation and AI Use
Presenting neat and tidy code is an important part of Python - one of the key ideas that Guido van Rossum had when creating Python was that code is read much more often than it is written, and so it makes sense to prioritise readability over writability.
Good, tidy, readable code will demonstrate that you are a competent programmer, and will even help to get you good marks in your assessments! Key elements of well presented code include:
- Follow the Rule of Thirds and make sure that your comments explain exactly what is going on.
- Make sure that variable, function and class names are all descriptive of what they do.
- Use
snake_casefor variable and function names. - Make sure your code is well structured, normally:
importstatements- functions
- main code
- Do not leave in any unnecessary testing material, such as
print()statements that do not contribute to the user experience. - Do not import libraries or functions that you are not using.
- Remember that you MUST adhere to the AI Policy, and you must use proper Version Control throughout your development process, as part of your assessment is your git log. Failing to do either of these things will likely result in a very low mark (see Marking Criteria).
For more guidance on how best to present your code, check out PEP8, the official Style Guide for Python Code.
Additional Pointers
- Don’t put it off, the longer you give yourself to complete this, the easier you will make it for yourself. Remember that this assignment is about consolidation of your knowledge from the course so far - you should expect to find it challenging, but remember that there is nothing in this assessment that you haven’t done already (or will do…) as part of the course practicals.
- Read these instructions carefully and in their entirety - particularly around submission - you must submit both your GitHub URL and Report on time for the submission to count.
- Don’t underestimate the importance of proper version control - a poor Git log could mean that you can only access a maximum score of 40%.
- Don’t try to use AI to do it for you - you won’t learn anything, and will likely get a very poor mark. You will get a far better mark from some code that does not quite work than you will from AI generated code!
- In the spirit of breaking the problem down into smaller jobs, I would recommend getting the quickest route working first, and then moving on to the least visible one.
- There are a lot of calculations to do here, so plan carefully to make sure that you don’t do any more than you need, and that you make full use of your understanding of both the algorithms themselves and relevant computing techniques to make sure your code is as efficient as possible.
- Think carefully about potential sources of error or bias in your data sources, and be sure to justify any decisions that you make.
- Don’t overlook the cartography - it is worth putting some effort into the map to show me that you can use and understand the plotting functions.
- Do not be tempted to use approaches that you do not understand - remember you will likely get more marks for a simpler approach that is well explained than for a more complex approach that you cannot fully explain.
- When explaining what you are doing - remember that I am more interested in the justification (i.e., what you are doing and why) than your implementation (i.e., which library or function you used) - remember that your report is intended to demonstrate a thorough understanding of the Geographical Information Science.
- If you do feel like you are starting to panic - talk to me!
Good Luck!!