Today getting a good raster processing environment is not so difficult. The computers are cheaper, storage components are bigger and prices are lower than any time before. Internet is full of tutorials and tips for people who want to start building their own remote sensing lab. This post will reintroduce three most common open-source raster and vector processing libraries which anyone can use – GDAL, RSGISLib Python library and Orfeo Toolbox.

In this article I have used a 64bit Lubuntu environment in Virtualbox with 2GB RAM and 10GB SATA space dedicated.

Installing GDAL

One of the amazing thing about Ubuntu is that has its own application channel or package archive (PPA) dedicated to spatial analysis and application. It’s called UbuntuGIS. Adopting the original DebianGIS, the stable platform of UbuntuGIS has lot of features providing all the stable releases while the unstable version has all the latest packages and libraries.

Geospatial Data Abstraction Library (GDAL) is a set of open-source command-line spatial data translation and analysis toolset for many data format. The easiest way to install GDAL with native Python of Lubuntu, use this line

sudo apt-get install python-gdal

And to get GDAL’s command line utility use this.

sudo apt-get install gdal-bin

Windows users can use a very useful little installer called OSGEO4W which can be used to install GDAL and other important utilities. Here is an amazing tutorial to install GDAL with Python binding in windows.

Making use of GDAL

To get a few of the basic information let’s use the gdalinfo utility.

>>>import os
>>>dataset = "/home/sunbeam/Workspace/LT51370432006355BKT00/LT51370432006_stacked.TIF"
>>>os.system('gdalinfo '+ dataset)

Driver: GTiff/GeoTIFF
Files: /home/sunbeam/Workspace/LT51370432006355BKT00/LT51370432006_stacked.TIF
Size is 7991, 7111
Coordinate System is:
PROJCS["WGS 84 / UTM zone 46N",
    GEOGCS["WGS 84",
            SPHEROID["WGS 84",6378137,298.257223563,
Origin = (142485.000000000000000,2825415.000000000000000)
Pixel Size = (30.000000000000000,-30.000000000000000)
Image Structure Metadata:
Corner Coordinates:
Upper Left  (  142485.000, 2825415.000) ( 89d26'38.08"E, 25d30'10.41"N)
Lower Left  (  142485.000, 2612085.000) ( 89d29'51.97"E, 23d34'47.43"N)
Upper Right (  382215.000, 2825415.000) ( 91d49'39.47"E, 25d32'28.94"N)
Lower Right (  382215.000, 2612085.000) ( 91d50'43.54"E, 23d36'54.22"N)
Center      (  262350.000, 2718750.000) ( 90d39'12.82"E, 24d33'52.18"N)
Band 1 Block=7991x1 Type=Float32, ColorInterp=Gray
Band 2 Block=7991x1 Type=Float32, ColorInterp=Undefined
Band 3 Block=7991x1 Type=Float32, ColorInterp=Undefined
Band 4 Block=7991x1 Type=Float32, ColorInterp=Undefined
Band 5 Block=7991x1 Type=Float32, ColorInterp=Undefined
Band 6 Block=7991x1 Type=Float32, ColorInterp=Undefined

Quite self-explanatory. GDAL can also access Landsat .tar.gz archive.

gdalinfo /landsat/LT51370432006355BKT00.tar.gz/LT51370432006355BKT00_B1.TIF

GDAL scripting environment can be accessed inside python with os.system. Using GDALWARP you can batch reproject many file at once.

gdalwarp -t_srs '+proj=utm +zone=46 +datum=WGS84' raw_spot.tif utm46.tif
Getting RSGISLib and GDAL with Miniconda

If you want to make your setup sandboxed and isolated from the default Lubuntu Python environment you might want to use Miniconda. Miniconda is a Python distribution platform and also a lighter version of a more robust platform called Anaconda. It’s completely free and can be used with both Python 2.x and 3.x in both x86 and x64 OS. RSGISLib is a python library for satellite image processing and analysis. Unfortunately RSGISLIB has some complication with Anaconda, so I used Miniconda. Miniconda comes with the mighty CONDA command tool so you can always install and update libraries you need. To install RSGISLib simply hit this line in the terminal

conda install –c osgeo rsgislib

This should download and install all the necessary libraries to your system. But Ubuntu users may face some dependency issue for DGAL. For Ubuntu users, use these command before conda command

sudo apt-get install libgdal1-dev
sudo apt-get install libgeos-dev

RSGISLib is only available for Linux and OSX users, windows users will have to compile from source.

Making use of RSGISLib

Not only for preprocessing, RSGISLib can be used to do quite high level of raster analysis, image segmentation, LiDAR processing, vector processing and other useful stuff.Here is a small example to mosaic a set of KEA images in a folder.

import rsgislib 
from rsgislib import imageutils 
import glob 
# Search for all files with the extension 'kea' 
inputList = glob.glob('./TestOutputs/Tiles/*.kea') 
outImage = './TestOutputs/injune_p142_casi_sub_utm_mosaic.kea' 
backgroundVal = 0. 
skipVal = 0. 
skipBand = 1 
overlapBehaviour = 0 
gdalformat = 'KEA' 
datatype = rsgislib.TYPE_32FLOAT 
imageutils.createImageMosaic(inputList, outImage, backgroundVal, skipVal, skipBand, overlapBehaviour, gdalformat, datatype)

To give projection to an image using another one use this.

from rsgislib import imageutils
inputImage = 'image_without_projection.kea'
refImage = 'image_with_projection.kea'
imageutils.copyProjFromImage(inputImage, refImage)

The segutils tool can be used for OBIA and image classification

#/usr/bin/env python
from rsgislib.segmentation import segutils

inputImage = 'palsar_hhhv.kea'
clumpsFile = 'palsar_hhhv_clumps_elim_final.kea'
meanImage = 'palsar_hhhv_clumps_elim_final_mean.kea'

# Run segmentation
segutils.runShepherdSegmentation(inputImage, clumpsFile,meanImage, numClusters=100, minPxls=100)

These segments can be used for further analysis with attribution and feature extraction.

Pages: 1 2