26 May 2010

As part of my Clojure experiments I’m taking a look at GeoTools and the Java Topologya Suite for working with geospatial data.

Clojure has been described as “A better Java than Java”. I’m not a Java programmer, but having access to Java libraries in Clojure is very useful, and Clojure has made the interop remarkably painless so far.

The quickstart example on the GeoTools documentation pages starts with a horrid Maven incantation which I converted to a leiningen project file. The source itself once converted to Clojure looks like this:

And the leiningen project.clj:

Running either of the functions pops up a dialog box for you to choose a shapefile, which is then loaded and displayed.

The clojure version is shorter than the Java version, can be tinkered with at the REPL, and doesn’t use any Maven.



blog comments powered by Disqus