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

2021-05-11 Thread Markus Neteler
Hi Juan,

On Tue, May 11, 2021 at 5:47 PM JUAN SEBASTIAN VINASCO SALINAS via
grass-user  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
___
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user


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

2021-05-11 Thread JUAN SEBASTIAN VINASCO SALINAS via grass-user
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. And the suggested activation does not work.  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.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "", line 1, in 
  File
"/home/juan/miniconda3/envs/iota2-env/lib/python3.6/site-packages/geopandas/io/file.py",
line 76, in read_file
with reader(path_or_bytes, **kwargs) as features:
  File
"/home/juan/miniconda3/envs/iota2-env/lib/python3.6/site-packages/fiona/env.py",
line 397, in wrapper
return f(*args, **kwargs)
  File
"/home/juan/miniconda3/envs/iota2-env/lib/python3.6/site-packages/fiona/__init__.py",
line 253, in open
layer=layer, enabled_drivers=enabled_drivers, **kwargs)
  File
"/home/juan/miniconda3/envs/iota2-env/lib/python3.6/site-packages/fiona/collection.py",
line 159, in __init__
self.session.start(self, **kwargs)
  File "fiona/ogrext.pyx", line 484, in fiona.ogrext.Session.start
  File "fiona/_shim.pyx", line 80, in fiona._shim.gdal_open_vector
fiona.errors.DriverError:
'/mnt/d/Datos_Landsat/nc_basic_spm_grass7/PERMANENT/vector/roadsmajor/head'
not recognized as a supported file format.

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?

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

Regards,
Juan
___
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user