[GRASS-user] Load Grass vector file into geopandas-fiona

Markus Neteler neteler at osgeo.org
Tue May 11 10:15:18 PDT 2021


Hi Juan,

On Tue, May 11, 2021 at 5:47 PM JUAN SEBASTIAN VINASCO SALINAS via
grass-user <grass-user at lists.osgeo.org> wrote:
>
>
> Hello everyone,
> I am trying to read a vector file stored in a GRASS database from geopandas-fiona.
>
> import fiona
> import geopandas as gpd
>
> fiona.supported_drivers["OGR_GRASS"] = "r"
> gdf = gpd.read_file('/mnt/d/Datos_Landsat/nc_basic_spm_grass7/PERMANENT/vector/roadsmajor/head')
>
> However it seems that fiona support for GRASS data is not enabled by default.

Yes, you need to also install the GDAL-GRASS-Plugin, see e.g.

https://grasswiki.osgeo.org/wiki/Compile_and_Install_Ubuntu#GDAL-GRASS-Plugin

(or get it ideally pre-compiled from your preferred operating system provider).

> And the suggested activation does not work.

Please explain what is suggested where along with the error (unless
you mean the one below).

>  I get the following error
>
> Traceback (most recent call last):
>   File "fiona/_shim.pyx", line 73, in fiona._shim.gdal_open_vector
>   File "fiona/_err.pyx", line 270, in fiona._err.exc_wrap_pointer
> fiona._err.CPLE_OpenFailedError: '/mnt/d/Datos_Landsat/nc_basic_spm_grass7/PERMANENT/vector/roadsmajor/head' not recognized as a supported file format.

Yes, this indicates that the driver is missing which has been
separated out to a stand-alone plugin for GDAL years ago (in order to
avoid circular dependencies).

...

> I think it is possible that the OGR build does not include the driver to read GRASS GIS data, but this is new ground for me. does anyone have experience with this integration?

Yes :-)

> I am running on a WSL2 and on a conda environment created with the following packages:
> - https://anaconda.org/iota2/grass (grass7.7)

Note that GRASS GIS 7.7 is fairly old.

> - https://anaconda.org/iota2/otb (Orfeo Toolbox 7.1)

Now, I am not quite familiar with WSL2 and conda... Do you need conda at all?
Is there a different way to get standard Ubuntu packages into WSL2...
(with apt-get install package-name since the package exists:
https://packages.ubuntu.com/focal/libgdal-grass).
Perhaps others know how that works on Windows.

Regards,
Markus

-- 
Markus Neteler, PhD
https://www.mundialis.de - free data with free software
https://grass.osgeo.org
https://courses.neteler.org/blog


More information about the grass-user mailing list