Skip to content

Commit

Permalink
DEP: Update to geopandas 1 (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
snowman2 authored Jun 26, 2024
1 parent b5744fd commit 96fed3f
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 26 deletions.
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports
- geocube version (`geocube --version`)
- rasterio version (`rio --version`)
- rasterio GDAL version (`rio --gdal-version`)
- fiona version (`fio --version`)
- fiona GDAL version (`fio --gdal-version`)
- pyogrio version (`python -c "import pyogrio; print(pyogrio.__version__)"`)
- pyogrio GDAL version (`python -c "import pyogrio; print(pyogrio.__gdal_version__)"`)
- Python version (`python -c "import sys; print(sys.version.replace('\n', ' '))"`)
- Operation System Information (`python -c "import platform; print(platform.platform())"`)

Expand All @@ -50,7 +50,7 @@ Environment (<code>conda list</code>):
<details>

```
$ conda list | grep -E "rasterio|xarray|gdal|fiona|scipy"
$ conda list | grep -E "rasterio|xarray|gdal|pyogrio|scipy"
```
</details>
Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/installation_issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ labels: installation-issues

#### Installation method/steps
- Installation method (conda, pip, from source, etc...)
- Please provide all commands/steps you used to install geocube and GDAL/rasterio/fiona.
- Please provide all commands/steps you used to install geocube and GDAL/rasterio/pyogrio.

#### Environment Information
- rioxarray version you are attempting to install
- rasterio version (`rio --version`)
- rasterio GDAL version (`rio --gdal-version`)
- fiona version (`fio --version`)
- fiona GDAL version (`fio --gdal-version`)
- pyogrio version (`fio --version`)
- pyogrio GDAL version (`fio --gdal-version`)
- Python version (`python -c "import sys; print(sys.version.replace('\n', ' '))"`)
- Operation System Information (`python -c "import platform; print(platform.platform())"`)
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
environment-name: test
create-args: >-
python=${{ matrix.python-version }}
geopandas<1
geopandas
numpy<2
netcdf4
odc-geo
Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Getting Started
and is powered by `GDAL <https://github.com/osgeo/gdal>`__ using:

- `rasterio <https://github.com/mapbox/rasterio>`__
- `fiona <https://github.com/toblerity/fiona>`__
- `pyogrio <https://github.com/geopandas/pyogrio>`__
- `odc-geo <https://github.com/opendatacube/odc-geo>`__


Expand Down
6 changes: 3 additions & 3 deletions geocube/_show_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ def _get_gdal_info():
proj_info: dict
system GDAL information
"""
import fiona
import pyogrio
import rasterio

blob = [
("fiona", importlib.metadata.version("fiona")),
("GDAL[fiona]", fiona.__gdal_version__),
("pyogrio", importlib.metadata.version("pyogrio")),
("GDAL[pyogrio]", pyogrio.__gdal_version__),
("rasterio", importlib.metadata.version("rasterio")),
("GDAL[rasterio]", rasterio.__gdal_version__),
]
Expand Down
10 changes: 2 additions & 8 deletions geocube/geo_utils/geobox.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from collections.abc import Iterable
from typing import Any, Optional, Union

import fiona.errors
import geopandas
import rioxarray # noqa: F401 pylint: disable=unused-import
import shapely.geometry.base
Expand Down Expand Up @@ -69,12 +68,7 @@ def load_vector_data(
logger = get_logger()

if isinstance(vector_data, (str, os.PathLike)):
try:
vector_data = geopandas.read_file(vector_data, include_fields=measurements)
except fiona.errors.DriverError as error:
if "ignore_fields" not in str(error):
raise
vector_data = geopandas.read_file(vector_data)
vector_data = geopandas.read_file(vector_data, columns=measurements)

elif not isinstance(vector_data, geopandas.GeoDataFrame):
vector_data = geopandas.GeoDataFrame(vector_data)
Expand All @@ -95,7 +89,7 @@ def load_vector_data(

# make sure projection is set
if not vector_data.crs:
vector_data.crs = "EPSG:4326"
vector_data.set_crs("EPSG:4326")
logger.warning(
"Projection not defined in `vector_data`."
" Setting to geographic (EPSG:4326)."
Expand Down
6 changes: 3 additions & 3 deletions geocube/xarray_extensions/vectorxarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ def to_geodataframe(self):
extra_coords = list(set(list(out_obj.coords)) - {"geometry"})
if extra_coords:
out_obj = out_obj.copy().reset_coords(extra_coords)
geodf = geopandas.GeoDataFrame(out_obj.to_dataframe().reset_index())
geodf.crs = self._obj.rio.crs
return geodf
return geopandas.GeoDataFrame(
out_obj.to_dataframe().reset_index(), crs=self._obj.rio.crs
)

def to_netcdf(self, *args, **kwargs):
"""
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins = numpy.typing.mypy_plugin
[mypy-appdirs]
ignore_missing_imports = True

[mypy-fiona.*]
[mypy-pyogrio.*]
ignore_missing_imports = True

[mypy-geopandas]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ requires-python = ">=3.10"
dependencies = [
"appdirs",
"click>=6.0",
"geopandas>=0.7,<1",
"geopandas>=1",
"odc_geo",
"rasterio>=1.3",
"rioxarray>=0.4",
Expand Down
4 changes: 2 additions & 2 deletions test/unit/test_show_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ def test_get_gdal_info():
gdal_info = _get_gdal_info()
assert "rasterio" in gdal_info
assert "GDAL[rasterio]" in gdal_info
assert "fiona" in gdal_info
assert "GDAL[fiona]" in gdal_info
assert "pyogrio" in gdal_info
assert "GDAL[pyogrio]" in gdal_info


def test_get_sys_info():
Expand Down

0 comments on commit 96fed3f

Please sign in to comment.