Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: InvalidVersion error when writing a file on disk with engine=fiona #3147

Closed
2 tasks done
remi-braun opened this issue Jan 17, 2024 · 5 comments · Fixed by #3148
Closed
2 tasks done

BUG: InvalidVersion error when writing a file on disk with engine=fiona #3147

remi-braun opened this issue Jan 17, 2024 · 5 comments · Fixed by #3148

Comments

@remi-braun
Copy link

remi-braun commented Jan 17, 2024

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of geopandas.

Issue alrerady reported in esri forum and stack overflow.


Code Sample, a copy-pastable example

import geopandas as gpd
from shapely.geometry import Point

p = Point(0, 1)
gdf = gpd.GeoDataFrame(geometry=[p], crs=4326)
gdf.to_file("path/to/file.shp")

or

from packaging.version import Version, InvalidVersion
import fiona
from fiona import Env as fiona_env
with fiona_env():
    gdal_version = fiona.env.get_gdal_release_name()
    Version(gdal_version)

Problem description

Impossible to write a vector on disk with fiona's engine.
297467541-64b4f5ee-c0e9-4fc2-8d04-9ea856659cc6

  1. When writing a file on disk, geopandas checks GDAL versions through fiona using the Version package
  2. fiona outputs a GDAL version not handled by Version (3.7.0e instead of 3.7.0)
  3. geopandas doesn't handle such exception (InvalidVersion) and fails

Expected Output

Handle the InvalidVersion error in this part of the code.

Output of geopandas.show_versions()

import geopandas
geopandas.show_versions()
SYSTEM INFO
-----------
python     : 3.9.18 [MSC v.1931 64 bit (AMD64)]
executable : C:\Users\rbraun\Anaconda3\envs\arcgispro-eo\python.exe
machine    : Windows-10-10.0.19045-SP0
GEOS, GDAL, PROJ INFO
---------------------
GEOS       : 3.11.2
GEOS lib   : None
GDAL       : 3.7.0e
GDAL data dir: None
PROJ       : 9.2.0
PROJ data dir: C:\Users\rbraun\Anaconda3\envs\arcgispro-eo\Library\share\proj
PYTHON DEPENDENCIES
-------------------
geopandas  : 0.14.2
numpy      : 1.22.4
pandas     : 2.0.2
pyproj     : 3.6.0
shapely    : 2.0.1
fiona      : 1.8.21
geoalchemy2: None
geopy      : 2.4.1
matplotlib : 3.6.3
mapclassify: 2.5.0
pygeos     : None
pyogrio    : 0.6.0
psycopg2   : None
pyarrow    : 14.0.2
rtree      : 1.1.0

Workaround

The workaround is to write the file on disk using pyogrio as stated here:

geopandas.options.io_engine = "pyogrio"
@martinfleis
Copy link
Member

How did you install GDAL that it comes with such a version?

@remi-braun
Copy link
Author

Unfortunately, it's the one coming with the ersi conda channel 🙄
I know this is on their garden, but if you could just handle the InvalidVersion error, this would be a big help 🙏

PS : I'm not the one having this bug, see the two linked issues in the header

@martinfleis
Copy link
Member

I suppose we could strip the version of the appended e. Though this is clearly an issue caused by Esri that should be solved by Esri. They take perfectly fine software, apparently adapt it in some way and produce invalid version tag the original software never had and never would've because the versioning system is not a random collection of numbers and letters as Esri assumes...

@remi-braun
Copy link
Author

remi-braun commented Jan 18, 2024

I know, I know, them having their own conda channel is a pain 😞
Unfortunatelly, I have no choice but using this software, and apparently this issues comes regularly.

They seems to be notified with the issue on their forum.

With geopandas 1.0.0 this may be automatically solved as the error doesn't happen with pyogrio.

@martinfleis
Copy link
Member

With geopandas 1.0.0 this may be automatically solved as the error doesn't happen with pyogrio.

For most of users yes, but Fiona will still be available and that code path shall work as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants