1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016 Leo Famulari <leo@famulari.name>
3 ;;; Copyright © 2016 Alex Griffin <a@ajgrf.com>
4 ;;; Copyright © 2017, 2018 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
5 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
6 ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
7 ;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
8 ;;; Copyright © 2018 Joshua Sierles, Nextjournal <joshua@nextjournal.com>
9 ;;; Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
11 ;;; This file is part of GNU Guix.
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26 (define-module (gnu packages geo)
27 #:use-module (guix build-system glib-or-gtk)
28 #:use-module (guix build-system gnu)
29 #:use-module (guix build-system python)
30 #:use-module (guix build-system scons)
31 #:use-module (guix build-system r)
32 #:use-module (guix download)
33 #:use-module ((guix licenses) #:prefix license:)
34 #:use-module (guix packages)
35 #:use-module (guix utils)
36 #:use-module (gnu packages boost)
37 #:use-module (gnu packages check)
38 #:use-module (gnu packages compression)
39 #:use-module (gnu packages databases)
40 #:use-module (gnu packages fontutils)
41 #:use-module (gnu packages cran)
42 #:use-module (gnu packages glib)
43 #:use-module (gnu packages gnome)
44 #:use-module (gnu packages gtk)
45 #:use-module (gnu packages image)
46 #:use-module (gnu packages icu4c)
47 #:use-module (gnu packages pcre)
48 #:use-module (gnu packages perl)
49 #:use-module (gnu packages pkg-config)
50 #:use-module (gnu packages python)
51 #:use-module (gnu packages statistics)
52 #:use-module (gnu packages web)
53 #:use-module (gnu packages webkit)
54 #:use-module (gnu packages wxwidgets)
55 #:use-module (gnu packages xml))
63 (uri (string-append "http://download.osgeo.org/geos/geos-"
68 "0ak5szby29l9l0vy43dm5z2g92xzdky20q1gc1kah1fnhkgi6nh4"))))
69 (build-system gnu-build-system)
71 (modify-phases %standard-phases
73 'unpack 'patch-test-shebangs
75 (substitute* '("tests/xmltester/testrunner.sh"
76 "tests/geostest/testrunner.sh")
77 (("/bin/sh") (which "sh")))
81 (home-page "https://geos.osgeo.org/")
82 (synopsis "Geometry Engine for Geographic Information Systems")
84 "GEOS provides a spatial object model and fundamental geometric
85 functions. It is a C++ port of the Java Topology Suite (JTS). As such,
86 it aims to contain the complete functionality of JTS in C++. This
87 includes all the OpenGIS Simple Features for SQL spatial predicate
88 functions and spatial operators, as well as specific JTS enhanced
90 (license (list license:lgpl2.1+ ; Main distribution.
91 license:zlib ; tests/xmltester/tinyxml/*
92 license:public-domain)))) ; include/geos/timeval.h
94 (define-public gnome-maps
100 (uri (string-append "mirror://gnome/sources/" name "/"
101 (version-major+minor version) "/"
102 name "-" version ".tar.xz"))
105 "0l40l7m9dyphvasiq1jxrn6ivavs1xwzn0bzz2x1z7x73955q783"))))
106 (build-system glib-or-gtk-build-system)
108 `(#:configure-flags ;; Ensure that geoclue is referred to by output.
109 (list (string-append "LDFLAGS=-L"
110 (assoc-ref %build-inputs "geoclue") "/lib")
111 (string-append "CFLAGS=-I"
112 (assoc-ref %build-inputs "geoclue") "/include"))
114 (modify-phases %standard-phases
115 (add-after 'install 'wrap
116 (lambda* (#:key inputs outputs #:allow-other-keys)
117 (let ((out (assoc-ref outputs "out"))
118 (gi-typelib-path (getenv "GI_TYPELIB_PATH"))
119 (goa-path (string-append
120 (assoc-ref inputs "gnome-online-accounts")
122 (webkitgtk-path (string-append
123 (assoc-ref inputs "webkitgtk")
125 (wrap-program (string-append out "/bin/gnome-maps")
126 `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-path))
128 ;; There seems to be no way to embed the path of
129 ;; libgoa-1.0.so.0, libwebkit2gtk-4.0.so.37 and
130 ;; libjavascriptcoregtk-4.0.so.18.
131 `("LD_LIBRARY_PATH" ":" prefix (,goa-path ,webkitgtk-path)))
134 `(("gobject-introspection" ,gobject-introspection)
135 ("intltool" ,intltool)
136 ("pkg-config" ,pkg-config)))
139 ("libchamplain" ,libchamplain)
141 ("libsecret" ,libsecret)
143 ("libgweather" ,libgweather)
145 ("gdk-pixbuf" ,gdk-pixbuf)
146 ("glib-networking" ,glib-networking)
148 ("geocode-glib" ,geocode-glib)
149 ("gfbgraph" ,gfbgraph)
152 ("gnome-online-accounts" ,gnome-online-accounts)
153 ("gsettings-desktop-schemas" ,gsettings-desktop-schemas)
155 ("webkitgtk" ,webkitgtk)))
158 (synopsis "Graphical map viewer and wayfinding program")
159 (description "GNOME Maps is a graphical map viewer. It uses map data from
160 the OpenStreetMap project. It can provide directions for walking, bicycling,
162 (home-page "https://wiki.gnome.org/Apps/Maps")
163 (license license:gpl2+)))
165 (define-public libgaiagraphics
167 (name "libgaiagraphics")
172 (uri (string-append "https://www.gaia-gis.it/gaia-sins/libgaiagraphics-"
176 "076afqv417ag3hfvnif0qc7qscmnq1dsf6y431yygwgf34rjkayc"))))
177 (build-system gnu-build-system)
179 `(("pkg-config" ,pkg-config)))
183 ("libjepeg-turbo" ,libjpeg-turbo)
185 ("libgeotiff" ,libgeotiff)
189 (synopsis "Gaia common graphics support")
190 (description "libgaiagraphics is a library supporting
191 common-utility raster handling methods.")
192 (home-page "https://www.gaia-gis.it/fossil/libgaiagraphics/index")
193 (license license:lgpl3+)))
195 (define-public libgeotiff
202 (uri (string-append "http://download.osgeo.org/geotiff/libgeotiff/libgeotiff-"
206 "0vjy3bwfhljjx66p9w999i4mdhsf7vjshx29yc3pn5livf5091xd"))
207 (modules '((guix build utils)))
210 ;; Remove .csv files, distributed from EPSG under a restricted
211 ;; license. See LICENSE for full license text.
212 (for-each delete-file (find-files "." "\\.csv$"))
213 ;; Now that we have removed the csv files, we need to modify the Makefile.
214 (substitute* "Makefile.in"
216 "all-am: Makefile $(LTLIBRARIES) $(HEADERS) geo_config.h\n")
217 (("^install-data-am: .*$")
218 "install-data-am: install-includeHEADERS"))))))
219 (build-system gnu-build-system)
221 `(("libjpeg-turbo" ,libjpeg-turbo)
227 (list (string-append "--with-zlib")
228 (string-append "--with-jpeg")
229 (string-append "--with-libtiff=" (assoc-ref %build-inputs "libtiff")))))
230 (synopsis "Library for handling GeoTIFF (geographic enabled TIFF)")
231 (description "libgeotiff is a library on top of libtiff for reading and
232 writing GeoTIFF information tags.")
233 (home-page "https://trac.osgeo.org/geotiff/")
234 ;; This is a mixture of various contributions under different licenses.
235 ;; Note that the EPSG database is NOT "free to use" as the LICENSE file
236 ;; states, as its commercial redistribution is restricted. Hence, we have
237 ;; removed it from the package.
238 (license (list license:public-domain
241 (license:non-copyleft "file://LICENSE"
242 "See LICENSE in the distribution.")))))
244 (define-public libspatialite
246 (name "libspatialite")
251 (uri (string-append "https://www.gaia-gis.it/gaia-sins/libspatialite-"
255 "16d4lpl7xrm9zy4gphy6nwanpjp8wn9g4wq2i2kh8abnlhq01448"))))
256 (build-system gnu-build-system)
258 `(("pkg-config" ,pkg-config)))
268 (modify-phases %standard-phases
269 ;; 3 tests are failing, ignore them:
270 (add-after 'unpack 'ignore-broken-tests
272 (substitute* '("test/Makefile.in")
273 (("\tcheck_sql_stm.*" all) "\tcheck_multithread$(EXEEXT) \\\n")
274 (("(\tch.*) check_v.*ble2.*$" all vt1) (string-append vt1 " \\\n"))
275 (("\tch.* (check_v.*ble4.*)$" all vt4) (string-append "\t" vt4)))
277 (synopsis "Extend SQLite to support Spatial SQL capabilities")
279 "SpatiaLite is a library intended to extend the SQLite core to support
280 fully fledged Spatial SQL capabilities.")
281 (home-page "https://www.gaia-gis.it/fossil/libspatialite/index")
282 ;; For the genuine libspatialite-sources holds:
283 ;; Any of the licenses MPL1.1, GPL2+ or LGPL2.1+ may be picked.
284 ;; Files under src/control_points are from GRASS
285 ;; and are licensed under GPL2+ only.
286 ;; src/md5.[ch]: Placed into the public domain by Alexander Peslyak.
287 (license (list license:gpl2+
290 license:public-domain))))
292 (define-public proj.4
298 (uri (string-append "http://download.osgeo.org/proj/proj-"
302 "1xw5f427xk9p2nbsj04j6m5zyjlyd66sbvl2bkg8hd1kx8pm9139"))))
303 (build-system gnu-build-system)
306 (modify-phases %standard-phases
307 (add-after 'unpack 'patch-test-paths
309 (substitute* '("nad/test27"
315 (("/bin/rm") (which "rm")))
317 ;; Precision problems on i686 and other platforms. See:
318 ;; https://web.archive.org/web/20151006134301/http://trac.osgeo.org/proj/ticket/255
319 ;; Disable failing test.
320 (add-after 'patch-test-paths 'ignore-failing-tests
322 (substitute* '("nad/Makefile.in")
323 (("\tPROJ_LIB.*" all) (string-append "#" all)))
327 (home-page "http://proj4.org/")
328 (synopsis "Cartographic Projections Library")
330 "Proj.4 is a library for converting coordinates between cartographic
332 (license (list license:expat
333 ;; src/PJ_patterson.c
337 ;; Embedded EPSG database.
338 (license:non-copyleft "http://www.epsg.org/TermsOfUse")
342 (define-public mapnik
349 (uri (string-append "https://github.com/mapnik/mapnik/releases/download/v"
350 version "/mapnik-v" version ".tar.bz2"))
353 "06frcikaj2mgz3abfk5h0z4j3hbksi0zikwjngbjv4p5f3pwxf8q"))))
354 (build-system scons-build-system)
358 ("freetype" ,freetype)
359 ("harfbuzz" ,harfbuzz)
361 ("libjpeg-turbo" ,libjpeg-turbo)
370 `(("pkg-config" ,pkg-config)))
372 `(#:scons ,scons-python2
375 (string-append "PREFIX=" %output)
376 (string-append "CUSTOM_LDFLAGS=-Wl,-rpath=" %output "/lib"))))
377 (home-page "http://mapnik.org/")
378 (synopsis "Toolkit for developing mapping applications")
379 (description "Mapnik is a toolkit for developing mapping applications. It
380 is basically a collection of geographic objects like maps, layers,
381 datasources, features, and geometries. At its core is a C++ shared library
382 providing algorithms and patterns for spatial data access and visualization.
383 The library does not rely on any specific windowing system and can be deployed
384 to any server environment. It is intended to play fair in a multi-threaded
385 environment and is aimed primarily, but not exclusively, at web-based
387 (license (list license:lgpl2.1+
388 ;; demo/viewer, demo/python/rundemo.py
390 ;; deps/boost, deps/mapbox, deps/agg/include/agg_conv_offset.h
392 ;; deps/mapnik/sparsehash
395 (license:non-copyleft "file://deps/agg/copying")))))
397 (define-public python2-mapnik
399 (name "python2-mapnik")
404 (uri (string-append "https://github.com/mapnik/python-mapnik/archive/v"
406 (file-name (string-append name "-" version ".tar.gz"))
409 "0w7wg72gnwmbjani9sqk42p2jwqkrl9hsdkawahni5m05xsifcb4"))))
410 (build-system python-build-system)
413 ("harfbuzz" ,harfbuzz)
415 ("libjpeg-turbo" ,libjpeg-turbo)
421 ("python2-pycairo" ,python2-pycairo)))
423 (let ((test-data-input
424 (lambda (repository version hash)
427 (uri (string-append "https://github.com/mapnik/" repository
428 "/archive/v" version ".tar.gz"))
429 (file-name (string-append "python-mapnik-" repository
430 "-" version ".tar.gz"))
431 (sha256 (base32 hash))))))
432 `(("python2-nose" ,python2-nose)
433 ;; Test data is released as separate tarballs
435 ,(test-data-input "test-data" "3.0.18"
436 "10cvgn5gxn8ldrszj24zr1vzm5w76kqk4s7bl2zzp5yvkhh8lj1n"))
438 ,(test-data-input "test-data-visual" "3.0.18"
439 "1cb9ghy8sis0w5fkp0dvwxdqqx44rhs9a9w8g9r9i7md1c40r80i")))))
441 `(#:python ,python-2 ; Python 3 support is incomplete, and the build fails
443 (modify-phases %standard-phases
444 ;; Unpack test data into the source tree
445 (add-after 'unpack 'unpack-submodules
446 (lambda* (#:key inputs #:allow-other-keys)
447 (let ((unpack (lambda (source target)
448 (with-directory-excursion target
449 (invoke "tar" "xvf" (assoc-ref inputs source)
450 "--strip-components=1")))))
451 (unpack "test-data" "test/data")
452 (unpack "test-data-visual" "test/data-visual"))))
453 ;; Skip failing tests
454 (add-after 'unpack 'skip-tests
456 (let ((skipped-tests (list "test_vrt_referring_to_missing_files"
457 "test_unicode_regex_replace"
458 "test_proj_antimeridian_bbox"
459 "test_render_with_scale_factor")))
460 (substitute* "setup.cfg"
461 (("\\[nosetests\\]" all)
462 (string-append all "\nexclude=^("
463 (string-join skipped-tests "|") ")$")))))))))
464 (home-page "https://github.com/mapnik/python-mapnik")
465 (synopsis "Python bindings for Mapnik")
466 (description "This package provides Python bindings for Mapnik.")
467 (license license:lgpl2.1+)))
469 (define-public spatialite-gui
471 (name "spatialite-gui")
476 (uri (string-append "https://www.gaia-gis.it/gaia-sins/spatialite_gui-"
480 "1r05dz9pyc8vsd2wbqxcsracpfbaamz470rcyp2myfpqwznv376b"))))
481 (build-system gnu-build-system)
483 `(("pkg-config" ,pkg-config)))
487 ("libgaiagraphics" ,libgaiagraphics)
488 ("libspatialite" ,libspatialite)
492 ("wxwidgets" ,wxwidgets-2)
494 (synopsis "Graphical user interface for SpatiaLite")
495 (description "Spatialite-gui provides a visual interface for viewing and
496 maintaining a spatialite database. You can easily see the structure of the
497 tables and data contents using point and click functions, many of which
498 construct common SQL queries, or craft your own SQL queries.")
499 (home-page "https://www.gaia-gis.it/fossil/spatialite_gui/index")
500 (license license:gpl3+)))
502 (define-public r-maps
509 (uri (cran-uri "maps" version))
512 "05i2ppl5z4p8rawgqmy3z4ia05fcblpq1vvrmrkgkkpdlhczx6hr"))))
513 (build-system r-build-system)
514 (home-page "https://cran.r-project.org/web/packages/maps")
515 (synopsis "Draw geographical maps")
516 (description "This package provies an R module for display of maps.
517 Projection code and larger maps are in separate packages ('mapproj' and
519 (license license:gpl2)))
521 (define-public r-mapproj
528 (uri (cran-uri "mapproj" version))
531 "1rggww8cbwv0vzlj5afzhbsbngg4bzj5znbkz7wmxsbshfbsm9b2"))))
532 (build-system r-build-system)
533 (propagated-inputs `(("r-maps" ,r-maps)))
534 (home-page "https://cran.r-project.org/web/packages/mapproj")
535 (synopsis "Map projection in R")
536 (description "This package converts latitude/longitude into projected
538 (license (list license:gpl2 ; The R interface
539 (license:non-copyleft ; The C code
540 "https://www.gnu.org/licenses/license-list.en.html#lucent102"
541 "Lucent Public License Version 1.02")))))
543 (define-public r-rgooglemaps
545 (name "r-rgooglemaps")
550 (uri (cran-uri "RgoogleMaps" version))
553 "0fsmlnhl4kw2j4972kfanzw9njhnzk695gsyw8g6yppsmz2clcaq"))))
554 (properties `((upstream-name . "RgoogleMaps")))
555 (build-system r-build-system)
556 (propagated-inputs `(("r-png" ,r-png)))
557 (home-page "https://cran.r-project.org/web/packages/RgoogleMaps")
558 (synopsis "Use Google Maps in R")
559 (description "This package serves two purposes: (i) Provide a comfortable R
560 interface to query the Google server for static maps, and (ii) Use the map as a
561 background image to overlay plots within R. This requires proper coordinate
563 (license license:gpl2+)))
565 (define-public r-geosphere
572 (uri (cran-uri "geosphere" version))
575 "186qdm5niq7v3d4w4rngx71znsgi44hnam7698bsx9ar5mg5b6wx"))))
576 (build-system r-build-system)
577 (propagated-inputs `(("r-sp" ,r-sp)))
578 (home-page "https://cran.r-project.org/web/packages/geosphere")
579 (synopsis "Spherical trigonometry")
580 (description "This package computes spherical trigonometry for geographic
581 applications. That is, compute distances and related measures for angular
582 (longitude/latitude) locations.")
583 (license license:gpl3+)))
585 (define-public r-ggmap
592 (uri (cran-uri "ggmap" version))
595 "0mssb09w818jv58h7mly9y181pzv22sgcd4a079cfpq04bs0wigw"))))
596 (build-system r-build-system)
598 `(("r-digest" ,r-digest)
599 ("r-geosphere" ,r-geosphere)
600 ("r-ggplot2" ,r-ggplot2)
602 ("r-mapproj" ,r-mapproj)
606 ("r-reshape2" ,r-reshape2)
607 ("r-rgooglemaps" ,r-rgooglemaps)
609 ("r-scales" ,r-scales)))
610 (home-page "https://github.com/dkahle/ggmap")
611 (synopsis "Spatial visualization with ggplot2")
612 (description "This package provides a collection of functions to visualize
613 spatial data and models on top of static maps from various online sources (e.g
614 Google Maps and Stamen Maps). It includes tools common to those tasks,
615 including functions for geolocation and routing.")
616 (license license:gpl2)))
625 "http://download.osgeo.org/gdal/" version "/gdal-"
629 "1951f7b69x3d1vic0rmq92q8f4bj3hbxnxmj5jl0cc3zg0isgmdr"))
630 (modules '((guix build utils)))
633 ;; TODO: frmts contains a lot more bundled code.
634 (for-each delete-file-recursively
639 "frmts/jpeg/libjpeg12"
640 "frmts/gtiff/libtiff"
641 "frmts/gtiff/libgeotiff"
643 "ogr/ogrsf_frmts/geojson/libjson"))))))
644 (build-system gnu-build-system)
648 (let-syntax ((with (syntax-rules ()
650 (string-append option "="
651 (assoc-ref %build-inputs input))))))
653 ;; TODO: --with-pcidsk, --with-pcraster
654 (with "--with-freexl" "freexl")
655 (with "--with-libjson-c" "json-c")
656 (with "--with-png" "libpng")
657 (with "--with-webp" "libwebp")
658 (with "--with-gif" "giflib")
659 (with "--with-jpeg" "libjpeg-turbo")
660 (with "--with-libtiff" "libtiff")
661 (with "--with-geotiff" "libgeotiff")
662 (with "--with-libz" "zlib")
665 (modify-phases %standard-phases
666 (add-before 'build 'fix-path
668 (substitute* "frmts/mrf/mrf_band.cpp"
669 (("\"../zlib/zlib.h\"") "<zlib.h>")))))))
675 ("libgeotiff" ,libgeotiff)
676 ("libjpeg-turbo" ,libjpeg-turbo)
682 (home-page "http://www.gdal.org/")
683 (synopsis "Raster and vector geospatial data format library")
684 (description "GDAL is a translator library for raster and vector geospatial
685 data formats. As a library, it presents a single raster abstract data model
686 and single vector abstract data model to the calling application for all
687 supported formats. It also comes with a variety of useful command line
688 utilities for data translation and processing.")
692 ;; frmts/gtiff/tif_float.c, frmts/pcraster/libcsf,
693 ;; ogr/ogrsf_frmts/dxf/intronurbs.cpp, frmts/pdf/pdfdataset.cpp
696 ;; frmts/hdf4/hdf-eos/*
697 ;; similar to the expat license, but without guarantee exclusion
698 (license:non-copyleft "file://frmts/hdf4/hdf-eos/README")
699 ;; frmts/grib/degrib/
700 license:public-domain ; with guarantee exclusion
702 ;; Some bsd-inspired license
703 (license:non-copyleft "file://port/LICENCE_minizip")
704 ;; alg/internal_libqhull
705 ;; Some 5-clause license
706 (license:non-copyleft "file://alg/internal_libqhull/COPYING.txt")
710 (define-public postgis
716 (uri (string-append "https://download.osgeo.org/postgis/source/postgis-"
720 "1hm8migjb53cymp4qvg1h20yqllmy9f7x0awv5450391i6syyqq6"))))
721 (build-system gnu-build-system)
725 (list (string-append "datadir=" (assoc-ref %outputs "out") "/share")
726 (string-append "docdir="(assoc-ref %outputs "out") "/share/doc")
727 (string-append "pkglibdir="(assoc-ref %outputs "out") "/lib")
728 (string-append "bindir=" (assoc-ref %outputs "out") "/bin"))
730 (modify-phases %standard-phases
731 (add-before 'build 'fix-install-path
732 (lambda* (#:key outputs #:allow-other-keys)
733 (substitute* '("raster/loader/Makefile" "raster/scripts/python/Makefile")
734 (("\\$\\(DESTDIR\\)\\$\\(PGSQL_BINDIR\\)")
735 (string-append (assoc-ref outputs "out") "/bin"))))))))
741 ("postgresql" ,postgresql)
745 ("pkg-config" ,pkg-config)))
746 (home-page "https://postgis.net")
747 (synopsis "Spatial database extender for PostgreSQL")
748 (description "PostGIS is a spatial database extender for PostgreSQL
749 object-relational database. It adds support for geographic objects allowing
750 location queries to be run in SQL.")
754 ;; loader/dbfopen, safileio.*, shapefil.h, shpopen.c
757 license:public-domain
759 license:bsd-3 ; files only say "BSD"
761 license:cc-by-sa3.0))))