1. Overview
We have developed a number of python plotting scripts for LSDTopoTools. In this documentation you will find instructions on installation and on their use.
1.1. Setting up Python the easy way
| Do not set up python in a vagrant server. Instead do it in your host operating system. The vagrant server is a stripped down version of Linux that cannot generate windows so you can have only limited functionality of these tools in a vagrant server. |
This is a quick guide. There are many options for setting up python but this is our preferred setup.
-
Download and install miniconda on your host machine.
-
Open a command prompt (use the start menu to search for cmd.exe)
-
Get our environment file.
-
Create the environment from that file with:
> conda env create -f environment.ymlI’m afraid this will take a little while.
-
Activate the environment:
> activate LSDTT
This environment does not include spyder, you can install it with conda install -n LSDTT spyder
|
1.2. Setting up python the hard way (without the environment.yml file)
| This is an alternative to the previous section! |
-
The best way to install python is miniconda. Currently everything we use is tested on Python 2.7, so use the Python 2.7 installer. However, we have attempted to maintain compatibility to python 3.x. If you use that, it should be okay, but please report any bugs on the github page.
Our visualisation routines involve some computation, and dealing with geospatial data. This means that there are a number of packages to install. This might take some time. If you are already using python for something critical you may consider setting up a virtual environment to ensure all of these new packages don’t break what you’ve already got. -
Once you have installed miniconda, you can go into a command prompt (windows) or terminal (MacOS and Linux) and get the other stuff you need. To get the command prompt in windows look for the cmd.exe program.
-
You should create a python environment for LSDTopoTools. Read about conda python environments here:
> conda config --add channels conda-forge > conda create --name LSDTT > conda install -n LSDTT shapely > conda install -n LSDTT fiona > conda install -n LSDTT rasterio > conda install -n LSDTT scipy > conda install -n LSDTT matplotlib > conda install -n LSDTT pandas > conda install -n LSDTT gdal > conda install -n LSDTT pyproj > conda install -n LSDTT descartes > conda install -n LSDTT spyder > conda activate LSDTT -
Every time you use our tools, you should activate the LSDTT python environment.
-
To run spyder you just type
spyderat the command line.Spyder needs an older version of a package called PyQt. If spyder doesn’t start correctly, run conda install pyqt=4.10 -fIt is entirely possible that we have forgotten some package, but if you run one of our scripts and it tells you the package is not found, just use condato install.
1.3. Using Spyder
Once you have installed python, you can use it from the command line (i.e. from a powershell or terminal window). However, you might prefer using a nice development environment that checks your code and has pretty colours and reassuring windows. When we are not using text editors (see our section [Text editors for modifying files]) we tend to use Spyder, which has an editor that can give you help with python packages and highlight your mistakes. You should have already installed it with conda install spyder, so to get it running go into a powershell or terminal window and just type:
> spyder
| You cannot run spyder on the vagrant machine since it has no windowing system. If you want to run Spyder you need to use your host operating system. This is the one of the reasons we encourage you to do your python installation on your host operating system and not the vagrant machine. |
2. Getting our plotting tools
Our vagrant setup has no graphic interface (you only interact with it through a terminal) so we suggest using your host operating system for python.
-
You need to clone our repository LSDMappingTools.
At the moment LSDMappingTools is a complete mess. It currently serves as a bit of a sandbox for visualisation development. One day we will clean it all up and make a nice, pretty release. But for now I’m afraid you’ll need to rely on this repository. -
If you don’t want to install git on your host operating system, you can clone the repository from your vagrant machine. Because of the clever way vagrant works you will be able to use these files in you host operating system.
$ cd /LSDTopoTools/Git_projects $ git clone https://github.com/LSDtopotools/LSDMappingTools.gitIn your host operating system these files will not be in /LSDTopoTools/Git_projects. They will be within theVagrantBoxes\LSDTopoTools\Git_projectsdirectory (wherever you put it. On windows I put mine in theCdirectory). -
Once you have this repository you can move on to our examples in the next chapter.
2.1. Fixing python gdal in windows
If you are using windows, there is a stupid bug in the conda gdal package where it cannot find the gdal data. To fix this:
-
Search for the file gcs.csv. Note the folder in which it is located. On my system it is in
C:\Miniconda2\Library\share\gdal -
Go into the control panel, go to system (or system and security, then system), click on advanced system settings and in system variables enter a new variable: GDAL_DATA. For the value of this enter the directory where the gdal data is that you fond above.