2017-06-20
After a surprisingly swift intro to Linux and bash the day will evolve around the GDAL library as well as the - relatively obscure - pktools
.
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
gdal_translate –formats | grep ENVI - find if gdal supports the format you want
ogrinfo can have very useful ouput an also supports SQL
statements
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))
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
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"
grep -v "inverted" - do an inverted grep
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.
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):
oft-stat -i INPUT.tif -o output.txt -um INPUT_MASK.tif >> INPUT_MASK = rasterized vector file
oft-clump
and oft-bb
can be used for preprocessing by finding the correct bounding boxes to do the zonal statistics with
todo: do a benchmark between QGIS, pktools and GRASS (maybe SAGA, perrygeo gist, Python package, starspan, R, R - multicore, PostGIS, GeoTools) zonal statistics and oft-stat (be aware of the zonal freaks)