Skip to content

Commit

Permalink
FIX: Manage case where we have a pd.Dataframe instead of a `gpd.Geo…
Browse files Browse the repository at this point in the history
…DataFrame` in `vectors.read` (reading a `.dbf` file for instance)
  • Loading branch information
remi-braun committed Jan 6, 2025
1 parent a9a480d commit 4d8893f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History

## 1.44.3 (2025-mm-dd)

- FIX: Manage case where we have a `pd.Dataframe` instead of a `gpd.GeoDataFrame` in `vectors.read` (reading a `.dbf` file for instance)

## 1.44.2 (2024-12-23)

- **ENH: Drop `isort`, `black` and `flake8` and use `ruff`**
Expand Down
7 changes: 6 additions & 1 deletion ci/test_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,14 @@ def test_read_gdb():

def test_read_dbf():
"""Test read from GDB"""
# DataFrame DBF (just check it works)
dbf_path = vectors_path() / "a0_source.dbf"
vectors.read(dbf_path)

# GeoDataFrame DBF
dbf_path = vectors_path() / "aoi.dbf"

fiona = vectors.read(dbf_path)
fiona = vectors.read(dbf_path, engine="fiona")
pyogrio = vectors.read(dbf_path, engine="pyogrio")

ci.assert_geom_equal(fiona, pyogrio)
Expand Down
6 changes: 4 additions & 2 deletions sertit/vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
You can use this only if you have installed sertit[full] or sertit[vectors]
"""

import contextlib
import logging
import os
import re
Expand Down Expand Up @@ -514,8 +515,9 @@ def read(
vect.attrs["name"] = path.get_filename(vector_path)

# Generate spatial index for optimization
if kwargs.get("compute_sindex", True) and not vect.has_sindex:
vect.sindex # noqa
with contextlib.suppress(AttributeError):
if kwargs.get("compute_sindex", True) and not vect.has_sindex:
vect.sindex # noqa

return vect

Expand Down

0 comments on commit 4d8893f

Please sign in to comment.