Liking cljdoc? Tell your friends :D


Clojure-idiomatic GDAL wrapper




GDAL (Geospatial Data Abstraction Library) is a library for reading and writing raster and vector geospatial data formats. GDAL supports more than 120 data formats such as NOAA GTX, NASA ELAS, HF2/HFZ, ESRI HDR, NetCDF, GeoTIFF, etc.

The clj-gdal project offers a Clojure wrapper around parts of the Java GDAL library.


  • Java 1.7 or higher (uses java.nio via the nio Clojure wrapper)
  • Java GDAL 1.11 library (included)

The Java library downloaded from Maven still requires that you have GDAL 2.x compiled on your system, as it references libraries which GDAL builds.


Add clj-gdal a dependency to your lein project:

Clojars Project

Then start up the Clojure REPL:

$ lein repl

The following examples use the development convenience namespace gdal-dev. This namespace has the following requires already done for you:

  (:require [clojure.pprint :as pp]
            [clojure.reflect :as reflect]
            [ :as log]
            [ :as repl]
            [gdal.core :as gdal]
            [ :as band]
            [gdal.dataset :as dataset])
  (:import [java.nio ByteBuffer]
           [org.gdal.gdalconst gdalconst]))

Top-level GDAL Functions> (gdal/init)
nil> (def data (gdal/open "LC80290302015263LGN00_B2.TIF"))
#'> (def tiff-data (gdal/open tiff-file))

Working with Dataset Objects> (dataset/get-size tiff-data)
[7681 7811]> (dataset/count-bands tiff-data)
1> (def band-data (dataset/get-band tiff-data 1))

Working with Band Objects> (band/get-checksum band-data)

Working with Projection Objects

Top-level data:

Datum Functions:> (proj/get-datum proj-data)
#object[org.apache.sis.referencing.datum.DefaultGeodeticDatum 0x659718b5 "GeodeticDatum[\"WGS_1984\",\n  Ellipsoid[\"WGS 84\", 6378137.0, 298.257223563],\n  Id[\"EPSG\", 6326, URI[\"urn:ogc:def:datum:EPSG::6326\"]]]"]> (proj/get-ellipsoid proj-data)
#object[org.apache.sis.referencing.datum.DefaultEllipsoid 0x1b798fdd "Ellipsoid[\"WGS 84\", 6378137.0, 298.257223563, Id[\"EPSG\", 7030, URI[\"urn:ogc:def:ellipsoid:EPSG::7030\"]]]"]> (proj/get-prime-meridian proj-data)
#object[org.apache.sis.referencing.datum.DefaultPrimeMeridian 0x4a616ee4 "PrimeMeridian[\"Greenwich\", 0.0]"]> (proj/get-bw-params proj-data)
#object["[Lorg.apache.sis.referencing.datum.BursaWolfParameters;" 0x5b736d8 "[Lorg.apache.sis.referencing.datum.BursaWolfParameters;@5b736d8"]

Coordinate Systems and Axes:> (proj/get-coord-system proj-data)
#object[org.apache.sis.referencing.cs.DefaultCartesianCS 0xaeb1198 "CS[Cartesian, 2]"]> (proj/get-coord-name proj-data)
"Cartesian CS: East (m), North (m)."> (proj/get-coord-dim proj-data)
2> (proj/get-axes proj-data)
(#object[org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis 0x1c2152ac "Axis[\"Easting (E)\", east, Unit[\"metre\", 1]]"] #object[org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis 0x4fbaa8a1 "Axis[\"Northing (N)\", north, Unit[\"metre\", 1]]"])> (proj/get-axis proj-data 1)
#object[org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis 0x4fbaa8a1 "Axis[\"Northing (N)\", north, Unit[\"metre\", 1]]"]> (proj/get-axis-name proj-data 1)
"Northing"> (proj/get-axis-unit proj-data 1)


Copyright © 2015-2016 Jonathan Morton, Duncan McGreggor

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

Can you improve this documentation? These fine people already did:
Duncan McGreggor & Jonathan Morton
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close