ceholden / open-geo-tutorial

Tutorial of basic remote sensing and GIS methodologies using open source software (GDAL in Python or R)
Other
245 stars 289 forks source link

Open Source Geoprocessing Tutorial

<img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/80x15.png" />

UPDATE

Check out an updated and extended version of this tutorial written by @patrickcgray. It's amazing and uses more "Pythonic" rasterio/fiona/shapely libraries instead of GDAL/OGR/OSR directly. It's amazing!

patrickcgray/open-geo-tutorial

Introduction

Tutorial of basic remote sensing and GIS methodologies using open source software (GDAL in Python). Tutorial covers workflow to perform image classification using machine learning classifiers:

  1. Introduction [Python] [R]
  2. The GDAL datatypes and objects [Python] [R]
  3. Your first vegetation index [Python] [R]
  4. Visualizing data [Python] [R]
  5. Vector data - the OGR library [Python] [R]
  6. Land cover classification [Python] [R]

Download

Materials and data for these lessons are included inside this repository under the example folder. I would recommend downloading all of the lesson material at once, instead of downloading individual files.

Two ways to download the entire repository include:

A caution:

Be careful trying to "right-click" and save files from repositories on Github, because this will save a HTML file linking to the file instead of the file itself. This has been a common source of confusion among people, especially if they are new to Github. It is possible to download individual files from a Github repository website, and can be done by clicking on a file listed on the repository site, and then clicking the "Download" button at the top right of the next web page (also next to the "History" button).

R Installation

The following R libraries will be needed for this tutorial:

Install them from within R as follows:

r install.packages(c('raster', 'rgdal', 'sp', 'randomForest'))

Python Installation

Thanks to the lovely people at binder, you can try running the lessons on their servers via magic:

Binder

To run the Jupyter Notebooks (formerly known as IPython Notebooks) and follow the tutorial locally, you will need to install Python and the libraries used in the tutorials. This installation can be accomplished in many ways, but I will list the two most common approaches:

conda

I recommend using the Anaconda Python distribution to make installation of the tutorial dependencies less complicated. After installing Anaconda or "miniconda" by following their instructions, you can install the dependencies as follows:

conda env create -f environment.yml
source activate open-geo-tutorial

pip

Assuming you already have Python installed, you could use the the Python package manager, pip, to install the dependencies.

Following "pip" convention, you can find all package requirements in the requirements.txt file. I would also recommend installing these packages into a virtual environment to avoid conflicts with existing versions of the required Python packages. To isolate these dependencies from the rest of your system, use virtualenv:

# Create virtual environment to isolate dependencies
virtualenv venv
# Activate virtual environment
source venv/bin/activate
# Install dependencies pip
install -r requirements.txt

You will need to have GDAL installed for Python to build the drivers against. You may have the Python bindings already built as part of GDAL's installation process.