After a surprisingly swift intro to Linux and bash the day will evolve around the GDAL library as well as the - relatively obscure - pktools.

Session 1 - gdal

EPSG / Spatial Referece Information

  • gdalinfo does not include the nodata value in the statistics, mind the data-type

  • gdal_translate can be used for tiling (as an example) -projwin ulx uly lrx lry

  • when cropping with gdal_translate (or any software) the cropping window does eventually not match perfectly, so the software will resample (or shift) automatically in the background

“The VRT driver is a format driver for GDAL that allows a virtual GDAL dataset to be composed from other GDAL datasets with repositioning, and algorithms potentially applied as well as various kinds of metadata altered or added.”

  • VRT can be used to link together many files or create subsets (extents) of images
1
gdal_translate --formats | grep ENVI - find if gdal supports the format you want
  • ogrinfo can have very useful ouput an also supports SQL statements
1
2
3
4
5
6
7
8
ogrinfo -al shape.shp
>>
OGRFeature(poly_fr_10poly):0
id (Integer64) = 2
region (Integer) = 2
POLYGON ((3872295.18072289 2681195.78313253,3915993.97590361 2666629.51807229,3901427.71084337 2615647.59036145,3872295.18072289 2681195.78313253))

Session 2 - gdal, bash scripting

1
2
openev TCmean01-10_1km.tif - quickly view a image or vector (uses GDAL)
STRL + \ - kill application
  • more AWK stuff

    for file in *.tif ; do
    gdalinfo -mm $file | grep “Min=” | awk -F “,” ‘{ print $2 }’
    done

    • set comma separation, print second column
  • get resolution of each TIF file and display only those with 240 pixel

1
2
3
4
5
6
7
8
9
10
11
for file in *.tif ; do
echo $file $(gdalinfo -mm $file | grep "Size is ")
done | grep "240"
- with added basename function:
for file in *.tif ; do
echo $(basename $file ) $(gdalinfo -mm $file | grep "Size is ")
done | grep "240"
1
grep -v "inverted" - do an inverted grep

Session 3 - pktools

pktools are based on gdal but go further in many ways; e.g. extract the bounding box coords without grepping or awking. Written in C++, good documentation, relatively narrow focus.

Session 4 - openforis oft-tools

  • quite usable tools from Open Foris

  • learning strategy: 1) GDAL 2) PKtools 3) Open Foris tools

  • oft-stat can be used for zonal statistics (very fast):

1
2
oft-stat -i INPUT.tif -o output.txt -um INPUT_MASK.tif
>> INPUT_MASK = rasterized vector file