Skip to content

Commit

Permalink
OPTIM: Compute the spatial index by default in vectors.read (set `v…
Browse files Browse the repository at this point in the history
…ectors.read(..., compute_sindex=False)` if you don't want to compute them)
  • Loading branch information
remi-braun committed Dec 17, 2024
1 parent 6ad7777 commit 08e1367
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- **ENH: Use `pyproject.toml` instead of `setup.py`**
- FIX: Fix too broad exception in case of `geopandas >= 1.0`
- FIX: Fix deprecation warning for `get_nodata_value_from_dtype` in `rasters_rio`
- OPTIM: Compute the spatial index by default in `vectors.read` (set `vectors.read(..., compute_sindex=False)` if you don't want to compute them)

## 1.44.1 (2024-12-12)

Expand Down
5 changes: 5 additions & 0 deletions sertit/vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ def read(
In case of an iterable, assumption is made it corresponds to geographic bounds. Mimics :code:`rasters.read(..., window=)`. If given, :code:`bbox` is ignored.
**kwargs: Additional arguments used in gpd.read_file.
You can also give :code:`file_list`, the list of files of the archive to get the vector from, as this operation is expensive when done with large archives stored on the cloud.
You can also set :code:`compute_sindex=False` to avoid computing the spatial index of the vector.
Returns:
gpd.GeoDataFrame: Read vector as a GeoDataFrame
Expand Down Expand Up @@ -512,6 +513,10 @@ def read(
vect.attrs["path"] = str(vector_path)
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

return vect


Expand Down

0 comments on commit 08e1367

Please sign in to comment.