3 [GDAL](https://gdal.org/) Scheme bindings for [Guile](https://www.gnu.org/software/guile/) programming language.
5 This library allows you to perform the following tasks:
7 * Open a raster file for reading and writing
8 * Access metadata of raster files
9 * Compute statistics of raster files
10 * Access layers of raster dataset
11 * Helper functions, providing idiomatic Scheme interface to the GDAL APIs
16 Read/write raster files using GDAL binding functions or helper functions:
21 (use-modules (gdal extension))
23 (use-modules (rnrs bytevectors))
25 ;; initialize GDAL by registering GDAL drivers
29 ;; read raster dataset using binding functions
31 (let* ((dataset (open-dataset "raster-small.txt" GA_READONLY))
32 (h-band (get-raster-band dataset 1))
33 (x-size (get-raster-band-x-size h-band))
34 (y-size (get-raster-band-y-size h-band))
35 (size (* x-size y-size))
36 (bv (make-s32vector size)))
38 (raster-io h-band GF_READ 0 0 x-size y-size bv x-size y-size GDT_INT32 0 0)
39 (for-each (lambda (i) (format #t "~a " (s32vector-ref bv i)))
44 ;; or read raster dataset using helper functions in the extension module
45 ;; providing more convenient way
47 (let* ((dataset (open-dataset "raster-small.txt" GA_READONLY))
48 (h-band (get-raster-band dataset 1))
49 (buf (make-buffer-all-from-band h-band GDT_INT32)))
50 (for-each-pixel (lambda (p) (format #t "~a " p)) buf))
52 ;; transform pixels using map-pixel function, returning a new binary buffer
53 ;; of type INT16 with 1 for pixels greater than 0, and 0 otherwise.
54 ;; use write-buffer-to-file to save the buffer into the disk in GeoTIFF format.
56 (let* ((dataset (open-dataset "raster-small.txt" GA_READONLY))
57 (h-band (get-raster-band dataset 1))
58 (buf (make-buffer-all-from-band h-band GDT_INT32)))
60 (define new-buf (map-pixel (lambda (p) (if (> p 0) 1 0))
61 buf #:buf-type GDT_INT16))
62 (write-buffer-to-file new-buf GDN_GTIFF
63 "new-raster-small.tif" #:no-data -1)))
67 See examples folder for more code samples.