Getting Started
Table of contents
Accessing Python
Today We’ll be using a UBC server with python already installed on it. If you want to install Python on your own computer, check out Anaconda.
- Anaconda will install many of the most commonly used python packages and set everything up for you.
- Anaconda won’t install every package we’re using today, but installing new packages is fairly straightforward.
Other resources: If you’re having issues with Python, a great place to check out is Stack Overflow. It is a popular forum where you can search, post, and answer coding questions. A related site that is more GIS focused site is Stack Exchange
Download the Code and Data
Video Reference: This video covers the steps in case you get lost.
1 Start a Jupyter Lab
UBC provides server space where you can run Python using Jupyter Lab. Login with your CWL. You’ll then be taken to a blank Jupyter lab. This is a good option for getting your bearings because nearly everything is already set up. You don’t have to worry about installing anything on your own system.
- This may be intimidating, but don’t worry, you don’t need to know command line to do this. I’ll walk you through step by step.
2 Open a terminal
We’re going to open a terminal and use command line clone (“download”) the Github workshop’s repository. In they Jupyter window, click File»New in the top right and select Terminal from the drop-down menu.
3 Clone the Repository
clone tells git (a file tracking software) to download a repository (collection of code, data, etc.) for this workshop. A folder called Geocoding-Web-Mapping-with-Python will appear after you clone the repository. You can explore it using the file viewer on the left, or you can use the command line. In the new terminal window that opens, paste this command and hit enter:
git clone https://github.com/ubc-library-rc/Geocoding-Web-Mapping-with-Python/
4 Installing a Package
pip (package installer for Python) is a tool we can use to install packages. In the terminal window type the command below and hit enter to install the Geopy package:
pip install geopy
5 Opening a Jupyter Notebook
In the file viewer you will see a folder called Geocoding-Web-Mapping-with-Python, double clicking the folder will open it. You’ll see a collection of folders and files. The one we will be working in today is called Python_Notebooks. In this folder you will see three files with .ipynb tag, that denotes a Jupyter Notebook. A Notebook is a collection of code and annotations that can be run interactively. Double click a notebook to open.
- Getting Started with Python.ipynb: will give you an introduction to data analysis with Python.
- Geocoding and Webmapping.ipynb: will give you an introduction to using Geopy to geocode and Folium to make web maps.
- Example Workflow.ipynb: Shows a practical application of how you can use geocoding and web mapping to track violence at the hands of Police in BC.