Compile and install GDAL-GRASS plugin: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
(define full path; +OpenSceneGraph/osgdem)
(→‎Compilation and Installation of Prerequisites: GDAL-GRASS-driver (own repo): https://github.com/OSGeo/gdal-grass)
 
(19 intermediate revisions by 2 users not shown)
Line 1: Line 1:
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 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]].
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]].
Line 8: Line 7:
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:


# [http://proj.maptools.org PROJ4] with [ftp://ftp.remotesensing.org/proj/proj-datumgrid-1.3.zip Datum grids] (expand in nad/ before compiling)
# [https://proj.org/ PROJ] with [https://download.osgeo.org/proj/ Datum grid file proj-data-XY.zip]
# Optional: [http://geos.refractions.net GEOS]
# Optionally: [https://libgeos.org GEOS]
# 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)
# Optionally: other packages
# [http://www.gdal.org GDAL/OGR] compiled '''without''' GRASS support (because we use the plugin!)
# [https://www.gdal.org GDAL/OGR] compiled '''without''' GRASS support (because we use the plugin!)
# GDAL-GRASS-driver (own repo): https://github.com/OSGeo/gdal-grass


==Compilation and Installation of the GDAL-GRASS plugin==
==Compilation and Installation of the GDAL-GRASS plugin==


Get the [http://download.osgeo.org/gdal/ GDAL/OGR-GRASS plugin] - file: gdal-grass-1.4.3.tar.gz (or later)
For '''GRASS GIS:'''
# Use the latest plugin '''source code''' version available. The code is fairly stable so the version doesn't need to match the latest GDAL version to keep working. Generally if an update is needed it will be issued, otherwise the existing (well tested) version will be left in place.
 
# 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'. A script to configure/install easily can be found [http://mpa.itc.it/markus/useful/conf_install_gdal_ogr_grass_plugin.sh here].
Download the [https://download.osgeo.org/gdal/CURRENT/ GDAL/OGR-GRASS plugin] - file: gdal-grass-x.y.z.tar.gz
 
NOTE: the plugin needs to have library path access the GRASS GIS libraries. The best way is to add a file <code>grass.conf</code> into the directory <code>/etc/ld.so.conf.d/</code> (edit as root) which contains the path to the GRASS libraries; then run <code>ldconfig</code>:
 
        sudo su
        nano /etc/ld.so.conf.d/grass.conf
        ldconfig
 
== Available libgdal-grass binary packages ==
 
* Debian: https://packages.debian.org/search?searchon=sourcenames&keywords=libgdal-grass
* Fedora: https://copr.fedorainfracloud.org/coprs/neteler/gdal-grass-plugin/
* openSuSe: https://build.opensuse.org/package/show/Application:Geo/libgdal-grass (outdated)
* Ubuntu: https://packages.ubuntu.com/search?keywords=libgdal-grass&searchon=names
* ...


==Usage of the plugin==
==Usage of the plugin==
Line 23: Line 37:
You always need to specify the '''full''' path to the data set:
You always need to specify the '''full''' path to the data set:


* GRASS raster map: gdalinfo grassdata/spearfish60/PERMANENT/cellhd/aspect
* GRASS raster map:
* GRASS vector map: ogrinfo -ro -so grassdata/spearfish60/PERMANENT/vector/roads/head
gdalinfo /path/to/grassdata/nc_spm_08_grass7/PERMANENT/cellhd/aspect
* Mapserver: should see both raster and vector maps, define connection properly in the .map file
* GRASS vector map:
* QGIS: needs it only for raster data
ogrinfo -ro -so /path/to/grassdata/nc_spm_08_grass7/PERMANENT/vector/roadsmajor/head
* OpenSceneGraph:  
* Mapserver: should be ablte to access both raster and vector maps, define connection properly in the .map file
  osgdem --xx 10 --yy 10 -t ${GRASSDATA}/cellhd/landuse96_28m \
* Geoserver: https://github.com/mundialis/geoserver-grass-raster-datastore
        --xx 10 --yy 10 -d ${GRASSDATA}/cellhd/elevation \
* [http://www.qgis.org QGIS]: only needs it for raster data
        -l 8 -v 0.1 -o north_carolina.ive
* [[OpenSceneGraph]]


==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 45: Line 59:
         ldd /usr/lib/gdalplugins/gdal_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/grass.conf" with this line (modify path as needed):
        /usr/grass-7.8.7/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):
Line 50: Line 71:
         # remember that you have to specify the absolute path:
         # remember that you have to specify the absolute path:
         export CPL_DEBUG=on
         export CPL_DEBUG=on
         gdalinfo /home/neteler/grassdata/spearfish60/PERMANENT/cellhd/roads
         gdalinfo $HOME/grassdata/nc_spm_08_grass7/PERMANENT/cellhd/aspect
         ogrinfo -summary $HOME/grassdata/spearfish60/PERMANENT/vector/roads/head
         ogrinfo -summary $HOME/grassdata/nc_spm_08_grass7/PERMANENT/vector/roadsmajor/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.8.7/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==
Line 57: Line 102:
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.
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
There are good instructions on source code compiling here [[:Category:Installation]].
 




[[Category:Documentation]]
[[Category:Documentation]]
[[Category:Installation]]
[[Category:Installation]]
[[Category:QGIS]]

Latest revision as of 20:48, 29 April 2022

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. PROJ with Datum grid file proj-data-XY.zip
  2. Optionally: GEOS
  3. Optionally: other packages
  4. GDAL/OGR compiled without GRASS support (because we use the plugin!)
  5. GDAL-GRASS-driver (own repo): https://github.com/OSGeo/gdal-grass

Compilation and Installation of the GDAL-GRASS plugin

For GRASS GIS:

Download the GDAL/OGR-GRASS plugin - file: gdal-grass-x.y.z.tar.gz

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

        sudo su
        nano /etc/ld.so.conf.d/grass.conf
        ldconfig

Available libgdal-grass 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/nc_spm_08_grass7/PERMANENT/cellhd/aspect
  • GRASS vector map:
ogrinfo -ro -so /path/to/grassdata/nc_spm_08_grass7/PERMANENT/vector/roadsmajor/head

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/grass.conf" with this line (modify path as needed):

        /usr/grass-7.8.7/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/nc_spm_08_grass7/PERMANENT/cellhd/aspect
        ogrinfo -summary $HOME/grassdata/nc_spm_08_grass7/PERMANENT/vector/roadsmajor/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.8.7/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 Category:Installation.