geocompx / geocompy

Geocomputation with Python: an open source book
https://py.geocompx.org/
Other
298 stars 54 forks source link

Error message about fiona 1.9+ #156

Closed Robinlovelace closed 1 year ago

Robinlovelace commented 1 year ago

After installing the packages with the following commands

curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-$(uname)-$(uname -m).sh"
bash Mambaforge-$(uname)-$(uname -m).sh
mamba env create -f environment.yml
mamba activate geocompy

I'm hitting this issue:


---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
Cell In[6], line 1
----> 1 gpd.read_file('data/world.gpkg', where='name_long="Tanzania"')

File ~/mambaforge/envs/geocompy/lib/python3.11/site-packages/geopandas/io/file.py:259, in _read_file(filename, bbox, mask, rows, engine, **kwargs)
    256     path_or_bytes = filename
    258 if engine == "fiona":
--> 259     return _read_file_fiona(
    260         path_or_bytes, from_bytes, bbox=bbox, mask=mask, rows=rows, **kwargs
    261     )
    262 elif engine == "pyogrio":
    263     return _read_file_pyogrio(
    264         path_or_bytes, bbox=bbox, mask=mask, rows=rows, **kwargs
    265     )

File ~/mambaforge/envs/geocompy/lib/python3.11/site-packages/geopandas/io/file.py:274, in _read_file_fiona(path_or_bytes, from_bytes, bbox, mask, rows, where, **kwargs)
    270 def _read_file_fiona(
    271     path_or_bytes, from_bytes, bbox=None, mask=None, rows=None, where=None, **kwargs
    272 ):
    273     if where is not None and not FIONA_GE_19:
--> 274         raise NotImplementedError("where requires fiona 1.9+")
    276     if not from_bytes:
    277         # Opening a file via URL or file-like-object above automatically detects a
    278         # zipped file. In order to match that behavior, attempt to add a zip scheme
    279         # if missing.
    280         if _is_zip(str(path_or_bytes)):

NotImplementedError: where requires fiona 1.9+
NotImplementedError: where requires fiona 1.9+
Robinlovelace commented 1 year ago

Seems I'm using an out-of-date version of fiona:

mamba list fiona
# packages in environment at /home/robin/mambaforge/envs/geocompy:
#
# Name                    Version                   Build  Channel
fiona                     1.8.22          py311h3f14cef_5    conda-forge
Robinlovelace commented 1 year ago

I tried:

mamba install -c conda-forge fiona>=1.9
zsh: 1.9 not found

But that failed as per error message above.

Robinlovelace commented 1 year ago

Looks like it requires a downgrade of rasterstats:

mamba install -c conda-forge 'fiona>=1.9'

                  __    __    __    __
                 /  \  /  \  /  \  /  \
                /    \/    \/    \/    \
███████████████/  /██/  /██/  /██/  /████████████████████████
              /  / \   / \   / \   / \  \____
             /  /   \_/   \_/   \_/   \    o \__,
            / _/                       \_____/  `
            |/
        ███╗   ███╗ █████╗ ███╗   ███╗██████╗  █████╗
        ████╗ ████║██╔══██╗████╗ ████║██╔══██╗██╔══██╗
        ██╔████╔██║███████║██╔████╔██║██████╔╝███████║
        ██║╚██╔╝██║██╔══██║██║╚██╔╝██║██╔══██╗██╔══██║
        ██║ ╚═╝ ██║██║  ██║██║ ╚═╝ ██║██████╔╝██║  ██║
        ╚═╝     ╚═╝╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝ ╚═╝  ╚═╝

        mamba (1.1.0) supported by @QuantStack

        GitHub:  https://github.com/mamba-org/mamba
        Twitter: https://twitter.com/QuantStack

█████████████████████████████████████████████████████████████

Looking for: ["fiona[version='>=1.9']"]

conda-forge/linux-64                                        Using cache
conda-forge/noarch                                          Using cache

Pinned packages:
  - python 3.11.*

Transaction

  Prefix: /home/robin/mambaforge/envs/geocompy

  Updating specs:

   - fiona[version='>=1.9']
   - ca-certificates
   - certifi
   - openssl

  Package        Version  Build            Channel                   Size
───────────────────────────────────────────────────────────────────────────
  Upgrade:
───────────────────────────────────────────────────────────────────────────

  - fiona         1.8.22  py311h3f14cef_5  conda-forge                   
  + fiona          1.9.1  py311h3f14cef_0  conda-forge/linux-64     876kB

  Downgrade:
───────────────────────────────────────────────────────────────────────────

  - rasterstats   0.18.0  pyhd8ed1ab_0     conda-forge                   
  + rasterstats   0.17.0  pyhd8ed1ab_0     conda-forge/noarch        18kB

  Summary:

  Upgrade: 1 packages
  Downgrade: 1 packages

  Total download: 895kB