descriptionGDAL Scheme bindings for Guile programming language.
ownergit
last changeMon, 30 May 2022 20:06:12 +0000 (13:06 -0700)
readme

Guile GDAL Bindings

GDAL Scheme bindings for Guile programming language.

This library allows you to perform the following tasks:

Example

Read/write raster files using GDAL binding functions or helper functions:


(use-modules (gdal))
(use-modules (gdal extension))

(use-modules (rnrs bytevectors))

;; initialize GDAL by registering GDAL drivers

(all-register)

;; read raster dataset using binding functions

(let* ((dataset (open-dataset "raster-small.txt" GA_READONLY))
       (h-band (get-raster-band dataset 1))
       (x-size (get-raster-band-x-size h-band))
       (y-size (get-raster-band-y-size h-band))
       (size (* x-size y-size))
       (bv (make-s32vector size)))
    (begin
        (raster-io h-band GF_READ 0 0 x-size y-size bv x-size y-size GDT_INT32 0 0)
        (for-each (lambda (i) (format #t "~a " (s32vector-ref bv i)))
          (iota size))))

(newline)

;; or read raster dataset using helper functions in the extension module
;; providing more convenient way

(let* ((dataset (open-dataset "raster-small.txt" GA_READONLY))
       (h-band (get-raster-band dataset 1))
       (buf (make-buffer-all-from-band h-band GDT_INT32)))
    (for-each-pixel (lambda (p) (format #t "~a " p)) buf))

;; transform pixels using map-pixel function, returning a new binary buffer
;; of type INT16 with 1 for pixels greater than 0, and 0 otherwise.
;; use write-buffer-to-file to save the buffer into the disk in GeoTIFF format.

(let* ((dataset (open-dataset "raster-small.txt" GA_READONLY))
       (h-band (get-raster-band dataset 1))
       (buf (make-buffer-all-from-band h-band GDT_INT32)))
    (begin
        (define new-buf (map-pixel (lambda (p) (if (> p 0) 1 0))
                                   buf #:buf-type GDT_INT16))
        (write-buffer-to-file new-buf GDN_GTIFF
                              "new-raster-small.tif" #:no-data -1)))

See examples folder for more code samples.

shortlog
2022-05-30 Ahmet Artu... Use html for the code block in README master
2022-05-30 Ahmet Artu... Update AUTHORS file
2021-12-30 Ahmet Artu... Add OGR set field bindings
2021-10-08 Ahmet Artu... Initialize project
heads
2 years ago master