There is a separate directory for each week's work. As we progress, suggested answers will be uploaded.
The foundations folder contains some warm up exercises to transition on to the course. There are two folders within:
- basic_features
- iterating
The basic_features folder contains a set of scripts introducing the basic Python features (data types, loops, plotting etc.). Other than 06_objects.py, which will be covered in week 2, these should already be familar to you and are included here for revision.
The iterating directory contains some exercises to practice using loops and work up to moving around a raster dataset.
Week 1 covers:
Aspects
- Github version control and code repository
- Computer basics
- Revision of loops and file I/O
Algorithm
- Introduction to algorithm design: Finding minima and sorting
Contains two scripts to demonstrate reading from a text file and writing to a text file. The data folder contains the data for the file reading example.
Contains a text file with some sample data to practice reading with the fileIO code.
Contains an example solution for a simple sort. Note that there are multiple sort solutions, such as bubble sort, and then many more complex and efficient algorithms.
Week 2 covers
Aspects
- Using the command line to make programmable programs
- Objects and classes
Algorithm
- Binary search: Loop and recursion
Contains an example of the main block in order to ease importing code in to other programs
Contains examples of document strings. Week 2 covers
Aspects
- Using the command line to make programmable programs
- Objects and classes
Algorithm
- Binary search: Loop and recursion
Contains two example python files, which can be used to alter the behaviour of a program at run time. This allows you to create a single python program and then reuse it with different input files, options etc.
commandExample.py: Minimum workable example of a command line
commandLineIllus.py: Illustrates the common command
Includes a script with a simple example of an object; a grouping of data and functions.
Contains some text data files for use in this week's exercises.
Contains the answer for week 2's algorithm.
binarySearches.py: contains suggested answers for binary search by loop and recursion
finishedQuartiles.py: uses the above to find quartiles in a sorted dataset
searchObject.py: begins an object for sorting data
makeData.py: makes data for testing algorithms
randomWages.py: generates random wage data for testing algorithms
Week 3 covers
Aspects
- Geospatial packages: pyproj and gdal
- A note on function input/output
- Function fitting
- A mention of pandas
- Geospatial data formats; HDF5
Algorithm
- Douglas-Peucker line generalization
Shows an example of using the dgal package to reproject raster or vector data.
Shows an example of fitting a function to data.
Demonstrates the difference between variables that point to an array and copying a whole array.
Shows an example of reading data into a pandas object.
Contains two files:
lvisClass.py: Shows an example of reading HDF data in to RAM, in this case using LVIS data.
lvisCompleteExample.py: Shows an examp[le of reprojecting and plotting data.
A function to find the orthogonal distance between a line and a point, to be used in the Douglas-Peucker line generalization algorithm.
An example solution for Douglas-Peucker line-generalisation. This one uses recursion and imports a script from a different folder usingf PYTHONPATH.
Contains data to be used in week 3's exercises.
Week 4 covers:
Aspects
- Geospatial data formats; geotiff
- Raster-vector calculations
Algorithm
- Batch processing: Raster-vector intersection
- Raster operations: Focal functions
Contains a function to pass a raster array to and then uses GDAL to write to a geotiff that can be read into GIS or back into python.
This contains four files:
lvisClass.py: A class to hold data from LVIS HDF5 files
processLVIS.py: Processes LVIS data to estimate ground elevation
lvisExample.py: An example of reading an LVIS file into RAM
lvisCompleteExample.py: Reprojects and plots LVIS data
Week 5 covers:
Aspects
- A few more geospatial packages
- More batch processing
- Raster analysis
Algorithm
- Practice all course material
Contains a minimum workable example of reading data into geopandas.
Contains a script to read a geotiff raster in to RAM.
Contains data to use in the above.
Contains lots of data files for use in the batch processing exercise.
Contains a function to interpolate a line and return a list of raster pixels intersected.