Difference between revisions of "Compile and install GDAL-GRASS plugin"

From GRASS-Wiki
Jump to: navigation, search
(+ERROR 2: compilation error libpq-fe.h: No such file or directory)
 
(34 intermediate revisions by 3 users not shown)
Line 1: Line 1:
In general, try to find precompiled packages (i.e., RPMs for most Linuxes, .deb for Debian, Install packages for MS-Windows etc). Check the GRASS download site for software providers.
+
The idea of the GDAL-GRASS plugin is to directly access GRASS raster and vector data from outside. Any GDAL enabled software (QGIS, R, ...) can read and write through the plugin from the GRASS database. It is sufficient to indicate the full path to the GRASS dataset (see below).
  
==Compilation==
 
  
The compilation order should be kept due to inter-dependencies between the packages. Please keep the order as seen below.
+
The compilation order should be kept due to inter-dependencies between the packages. Please keep the order as seen below. GRASS compilation is explained in [[Compile and Install]].
  
==Installation==
+
==Compilation and Installation of Prerequisites==
  
 
The install order should be kept due to inter-dependencies between the packages. Please keep the order or install all in a single step:
 
The install order should be kept due to inter-dependencies between the packages. Please keep the order or install all in a single step:
  
# PROJ4
+
# [https://proj4.org/ PROJ4] with [http://download.osgeo.org/proj/ Datum grids file proj-datumgrid-1.X.zip] (expand in nad/ subdirectory before compiling PROJ)
# Optional: GEOS
+
# Optional: [https://trac.osgeo.org/geos/ GEOS]
# Optional: PostgreSQL, mySQL, unixODBC, sqlite (but needed for QGIS)
+
# Optional: [http://www.postgresql.org PostgreSQL], [http://www.mysql.org mySQL], [http://www.unixodbc.org unixODBC], [http://www.sqlite.org SQLite] (SQLite is needed for QGIS)
# GDAL/OGR without GRASS support
+
# [http://www.gdal.org GDAL/OGR] compiled '''without''' GRASS support (because we use the plugin!)
# GRASS 6
 
# GDAL/OGR-GRASS plugin - file: gdal-grass-1.3.1.1.tar.gz (or later) [1] NOTE: the plugin needs to see the GRASS libraries . The best way is to add a file 'grass6.conf' into the directory /etc/ld.so.conf.d (edit as root) which contains the path to the GRASS libraries; then run 'ldconfig'.
 
# QGIS with GRASS support
 
  
[1] New plugin version as of 19 Oct 2005, requires GDAL 1.3.1 or later
+
==Compilation and Installation of the GDAL-GRASS plugin==
 +
 
 +
For '''GRASS GIS 7:'''
 +
 
 +
Get the [http://download.osgeo.org/gdal/2.4.0/ GDAL/OGR-GRASS 7 plugin] - file: gdal-grass-2.4.0.tar.gz (or later)
 +
# NOTE: the plugin needs to "see" the GRASS GIS libraries. The best way is to add a file 'grass7.conf' into the directory /etc/ld.so.conf.d/ (edit as root) which contains the path to the GRASS libraries; then run 'ldconfig'.
 +
 
 +
== Available binary packages ==
 +
* Debian: https://packages.debian.org/source/stretch/libgdal-grass
 +
* Fedora: https://copr.fedorainfracloud.org/coprs/neteler/gdal-grass-plugin/
 +
* openSuSe: https://build.opensuse.org/package/show/Application:Geo/libgdal-grass
 +
* Ubuntu: https://packages.ubuntu.com/bionic/libgdal-grass
 +
 
 +
==Usage of the plugin==
 +
 
 +
You always need to specify the '''full''' path to the data set:
 +
 
 +
* GRASS raster map:
 +
gdalinfo /path/to/grassdata/spearfish60/PERMANENT/cellhd/aspect
 +
* GRASS vector map:
 +
ogrinfo -ro -so /path/to/grassdata/spearfish60/PERMANENT/vector/roads/head
 +
* Mapserver: should see both raster and vector maps, define connection properly in the .map file
 +
* Geoserver: probably via GDAL support
 +
* [http://www.qgis.org QGIS]: only needs it for raster data
 +
* [[OpenSceneGraph]]
 +
 
 +
== GRASS GIS 7 support ==
 +
 
 +
Download the source code of the plugin with GRASS GIS 7 support (check there for any later version):
 +
  http://download.osgeo.org/gdal/2.4.3/gdal-grass-2.4.3.tar.gz
  
 
==Troubleshooting==
 
==Troubleshooting==
  
All stuff installed but QGIS doesn't see GRASS or r.out.gdal doesn't work?
+
=== All stuff installed but QGIS doesn't see GRASS or r.out.gdal doesn't work? ===
  
 
* Check if GDAL finds the plugin:
 
* Check if GDAL finds the plugin:
Line 30: Line 55:
 
* Check if the GRASS libs are found by the plugin. All libraries should be found (maybe you forgot to run 'ldconfig' if you didn't install from RPMs?):
 
* Check if the GRASS libs are found by the plugin. All libraries should be found (maybe you forgot to run 'ldconfig' if you didn't install from RPMs?):
  
         ldd /usr/lib/gdalplugins/grass_GRASS.so
+
         ldd /usr/lib/gdalplugins/gdal_GRASS.so
 
         ldd /usr/lib/gdalplugins/ogr_GRASS.so
 
         ldd /usr/lib/gdalplugins/ogr_GRASS.so
 +
 +
If not, create as root user the file "/etc/ld.so.conf.d/grass6.conf" with this line (modify path as needed):
 +
        /usr/grass-7.4.3/lib/
 +
 +
Then run "ldconfig" as root user.
 +
 +
=== Still failing ? ===
  
 
* Check if the GRASS plugins are in the right directory (check the 'Auto register' directory reported in the output):
 
* Check if the GRASS plugins are in the right directory (check the 'Auto register' directory reported in the output):
  
 +
        # remember that you have to specify the absolute path:
 
         export CPL_DEBUG=on
 
         export CPL_DEBUG=on
 +
        gdalinfo $HOME/grassdata/spearfish60/PERMANENT/cellhd/roads
 
         ogrinfo -summary $HOME/grassdata/spearfish60/PERMANENT/vector/roads/head
 
         ogrinfo -summary $HOME/grassdata/spearfish60/PERMANENT/vector/roads/head
 +
 +
=== ERROR 1: libgrass_I.so: cannot open shared object file: No such file or directory ===
 +
 +
The path to "libgrass_I.so" is missing from LD_LIBRARY_PATH. To solve this, create as root user the file "/etc/ld.so.conf.d/grass6.conf" with this line (modify path as needed):
 +
        /usr/grass-7.4.3/lib/
 +
 +
Then run "ldconfig" as root user.
 +
 +
=== ERROR 2: compilation error libpq-fe.h: No such file or directory ===
 +
 +
You get
 +
 +
        /usr/local/grass78/grass78/include/grass/vect/dig_structs.h:31:10:
 +
        fatal error: libpq-fe.h: No such file or directory
 +
          #include <libpq-fe.h>
 +
                  ^06:45, 7 January 2020 (PST)06:45, 7 January 2020 (PST)~
 +
        compilation terminated.
 +
        Makefile:43: recipe for target 'ogrgrassdriver.o' failed
 +
        make: *** [ogrgrassdriver.o] Error 1
 +
 +
Solution:
 +
        ./configure --with-postgres-includes=$(pg_config --includedir)
 +
 +
... then compile.
  
 
==Further Instructions==
 
==Further Instructions==
  
If you are still having trouble, please also vist GRASS for Fedora Core 4 for more detailed GRASS and GDAL compilation and installation instructions developed by Isaac Ullah for Fedora Core 4.
+
If you are still having trouble, please also visit "GRASS for Fedora Core 4" for more detailed GRASS and GDAL compilation and installation instructions developed by Isaac Ullah for Fedora Core 4.
 +
 
 +
There are good instructions on source code compiling here http://casoilresource.lawr.ucdavis.edu/drupal/node/123
 +
 
 +
 
 +
 
 +
[[Category:Documentation]]
 +
[[Category:Installation]]
 +
[[Category:QGIS]]

Latest revision as of 07:45, 7 January 2020

The idea of the GDAL-GRASS plugin is to directly access GRASS raster and vector data from outside. Any GDAL enabled software (QGIS, R, ...) can read and write through the plugin from the GRASS database. It is sufficient to indicate the full path to the GRASS dataset (see below).


The compilation order should be kept due to inter-dependencies between the packages. Please keep the order as seen below. GRASS compilation is explained in Compile and Install.

Compilation and Installation of Prerequisites

The install order should be kept due to inter-dependencies between the packages. Please keep the order or install all in a single step:

  1. PROJ4 with Datum grids file proj-datumgrid-1.X.zip (expand in nad/ subdirectory before compiling PROJ)
  2. Optional: GEOS
  3. Optional: PostgreSQL, mySQL, unixODBC, SQLite (SQLite is needed for QGIS)
  4. GDAL/OGR compiled without GRASS support (because we use the plugin!)

Compilation and Installation of the GDAL-GRASS plugin

For GRASS GIS 7:

Get the GDAL/OGR-GRASS 7 plugin - file: gdal-grass-2.4.0.tar.gz (or later)

  1. NOTE: the plugin needs to "see" the GRASS GIS libraries. The best way is to add a file 'grass7.conf' into the directory /etc/ld.so.conf.d/ (edit as root) which contains the path to the GRASS libraries; then run 'ldconfig'.

Available binary packages

Usage of the plugin

You always need to specify the full path to the data set:

  • GRASS raster map:
gdalinfo /path/to/grassdata/spearfish60/PERMANENT/cellhd/aspect
  • GRASS vector map:
ogrinfo -ro -so /path/to/grassdata/spearfish60/PERMANENT/vector/roads/head
  • Mapserver: should see both raster and vector maps, define connection properly in the .map file
  • Geoserver: probably via GDAL support
  • QGIS: only needs it for raster data
  • OpenSceneGraph

GRASS GIS 7 support

Download the source code of the plugin with GRASS GIS 7 support (check there for any later version):

 http://download.osgeo.org/gdal/2.4.3/gdal-grass-2.4.3.tar.gz

Troubleshooting

All stuff installed but QGIS doesn't see GRASS or r.out.gdal doesn't work?

  • Check if GDAL finds the plugin:
        gdal_translate --formats | grep -i grass
        GRASS (ro): GRASS Database Rasters (5.7+)
  • Check if the GRASS libs are found by the plugin. All libraries should be found (maybe you forgot to run 'ldconfig' if you didn't install from RPMs?):
        ldd /usr/lib/gdalplugins/gdal_GRASS.so
        ldd /usr/lib/gdalplugins/ogr_GRASS.so

If not, create as root user the file "/etc/ld.so.conf.d/grass6.conf" with this line (modify path as needed):

        /usr/grass-7.4.3/lib/

Then run "ldconfig" as root user.

Still failing ?

  • Check if the GRASS plugins are in the right directory (check the 'Auto register' directory reported in the output):
        # remember that you have to specify the absolute path:
        export CPL_DEBUG=on
        gdalinfo $HOME/grassdata/spearfish60/PERMANENT/cellhd/roads
        ogrinfo -summary $HOME/grassdata/spearfish60/PERMANENT/vector/roads/head

ERROR 1: libgrass_I.so: cannot open shared object file: No such file or directory

The path to "libgrass_I.so" is missing from LD_LIBRARY_PATH. To solve this, create as root user the file "/etc/ld.so.conf.d/grass6.conf" with this line (modify path as needed):

        /usr/grass-7.4.3/lib/

Then run "ldconfig" as root user.

ERROR 2: compilation error libpq-fe.h: No such file or directory

You get

        /usr/local/grass78/grass78/include/grass/vect/dig_structs.h:31:10:
        fatal error: libpq-fe.h: No such file or directory
         #include <libpq-fe.h>
                  ^06:45, 7 January 2020 (PST)06:45, 7 January 2020 (PST)~
        compilation terminated.
        Makefile:43: recipe for target 'ogrgrassdriver.o' failed
        make: *** [ogrgrassdriver.o] Error 1

Solution:

        ./configure --with-postgres-includes=$(pg_config --includedir)

... then compile.

Further Instructions

If you are still having trouble, please also visit "GRASS for Fedora Core 4" for more detailed GRASS and GDAL compilation and installation instructions developed by Isaac Ullah for Fedora Core 4.

There are good instructions on source code compiling here http://casoilresource.lawr.ucdavis.edu/drupal/node/123