From 2269d4df543b32d133180c4e06ba364c8cea3f49 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Mon, 14 Apr 2025 15:11:54 +1200 Subject: [PATCH 1/6] Bump minimum supported version to geopandas>=1.0 Bumps minimum supported GeoPandas version to 1.0 in the pyproject.toml and environment.yml files. Xref https://github.com/GenericMappingTools/pygmt/issues/3456 --- environment.yml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/environment.yml b/environment.yml index e96f473f7be..5218db6f48e 100644 --- a/environment.yml +++ b/environment.yml @@ -14,7 +14,7 @@ dependencies: - packaging # Optional dependencies - contextily - - geopandas + - geopandas>=1.0 - ipython - pyarrow-core - rioxarray diff --git a/pyproject.toml b/pyproject.toml index f0d29b016b4..55fc8424163 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,7 +46,7 @@ dynamic = ["version"] [project.optional-dependencies] all = [ "contextily", - "geopandas", + "geopandas>=1.0", "IPython", # 'ipython' is not the correct module name. "pyarrow", "rioxarray", From 360e3e8f9604f0b6b2a3f1de722936ef247602fc Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Mon, 14 Apr 2025 15:13:20 +1200 Subject: [PATCH 2/6] Test geopandas=1.0 in ci_tests_legacy.yaml --- .github/workflows/ci_tests_legacy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_tests_legacy.yaml b/.github/workflows/ci_tests_legacy.yaml index 65d07498781..770c1263cc5 100644 --- a/.github/workflows/ci_tests_legacy.yaml +++ b/.github/workflows/ci_tests_legacy.yaml @@ -67,7 +67,7 @@ jobs: netCDF4 packaging contextily - geopandas + geopandas=1.0 ipython pyarrow-core rioxarray From 7294713062e62eb68df0960aaeb6155b25c901ef Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Mon, 14 Apr 2025 15:44:12 +1200 Subject: [PATCH 3/6] Temporarily trigger Legacy Tests --- .github/workflows/ci_tests_legacy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_tests_legacy.yaml b/.github/workflows/ci_tests_legacy.yaml index 770c1263cc5..267f00e0068 100644 --- a/.github/workflows/ci_tests_legacy.yaml +++ b/.github/workflows/ci_tests_legacy.yaml @@ -12,7 +12,7 @@ on: # push: # branches: [ main ] # Uncomment the 'pull_request' line below to trigger the workflow in PR - # pull_request: + pull_request: # types: [ready_for_review] # paths: # - 'pygmt/**' From 0309580526068445e3c04b60967193dc62969ff3 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Mon, 14 Apr 2025 15:50:08 +1200 Subject: [PATCH 4/6] Remove workaround for geopandas<1 in pygmt/helpers/tempfile.py Workaround added in #3247 for geopandas v0.x and v1.x compatibility. --- pygmt/helpers/tempfile.py | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/pygmt/helpers/tempfile.py b/pygmt/helpers/tempfile.py index 6995be1db98..033e34c3a46 100644 --- a/pygmt/helpers/tempfile.py +++ b/pygmt/helpers/tempfile.py @@ -9,7 +9,6 @@ from tempfile import NamedTemporaryFile import numpy as np -from packaging.version import Version def unique_name() -> str: @@ -144,34 +143,16 @@ def tempfile_from_geojson(geojson): # https://github.com/geopandas/geopandas/issues/967#issuecomment-842877704 # https://github.com/GenericMappingTools/pygmt/issues/2497 int32_info = np.iinfo(np.int32) - # TODO(GeoPandas>=1.0): Remove the workaround for GeoPandas < 1. - # The default engine is "fiona" in v0.x and "pyogrio" in v1.x. - if Version(gpd.__version__).major < 1: # GeoPandas v0.x - # The default engine 'fiona' supports the 'schema' parameter. - if geojson.index.name is None: - geojson.index.name = "index" - geojson = geojson.reset_index(drop=False) - schema = gpd.io.file.infer_schema(geojson) - for col, dtype in schema["properties"].items(): - if dtype in {"int", "int64"}: - overflow = ( - geojson[col].max() > int32_info.max - or geojson[col].min() < int32_info.min - ) - schema["properties"][col] = "float" if overflow else "int32" - geojson[col] = geojson[col].astype(schema["properties"][col]) - ogrgmt_kwargs["schema"] = schema - else: # GeoPandas v1.x. - # The default engine "pyogrio" doesn't support the 'schema' parameter - # but we can change the dtype directly. - for col in geojson.columns: - if geojson[col].dtype.name in {"int", "int64", "Int64"}: - overflow = ( - geojson[col].max() > int32_info.max - or geojson[col].min() < int32_info.min - ) - dtype = "float" if overflow else "int32" - geojson[col] = geojson[col].astype(dtype) + # The default engine "pyogrio" doesn't support the 'schema' parameter + # but we can change the dtype directly. + for col in geojson.columns: + if geojson[col].dtype.name in {"int", "int64", "Int64"}: + overflow = ( + geojson[col].max() > int32_info.max + or geojson[col].min() < int32_info.min + ) + dtype = "float" if overflow else "int32" + geojson[col] = geojson[col].astype(dtype) # Using geopandas.to_file to directly export to OGR_GMT format geojson.to_file(**ogrgmt_kwargs) except AttributeError: From 0aea1a189c4f030b380d2d8cb5bda94a1cc3021d Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Mon, 14 Apr 2025 16:23:36 +1200 Subject: [PATCH 5/6] Revert "Temporarily trigger Legacy Tests" This reverts commit 7294713062e62eb68df0960aaeb6155b25c901ef. --- .github/workflows/ci_tests_legacy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_tests_legacy.yaml b/.github/workflows/ci_tests_legacy.yaml index 267f00e0068..770c1263cc5 100644 --- a/.github/workflows/ci_tests_legacy.yaml +++ b/.github/workflows/ci_tests_legacy.yaml @@ -12,7 +12,7 @@ on: # push: # branches: [ main ] # Uncomment the 'pull_request' line below to trigger the workflow in PR - pull_request: + # pull_request: # types: [ready_for_review] # paths: # - 'pygmt/**' From dc489dda3ec06082d0a39ad5dd3545fb1f2a320c Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Tue, 15 Apr 2025 07:53:53 +1200 Subject: [PATCH 6/6] Remove geopandas <1 and >=1 pin in ci_tests.yaml --- .github/workflows/ci_tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index 3255c9f02c8..262e8ffddb1 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -75,13 +75,13 @@ jobs: numpy-version: '1.25' pandas-version: '=2.1' xarray-version: '=2023.04' - optional-packages: ' contextily geopandas<1 ipython pyarrow-core rioxarray sphinx-gallery' + optional-packages: ' contextily geopandas ipython pyarrow-core rioxarray sphinx-gallery' # Python 3.13 + core packages (latest versions) + optional packages - python-version: '3.13' numpy-version: '2.2' pandas-version: '' xarray-version: '' - optional-packages: ' contextily geopandas>=1.0 ipython pyarrow-core rioxarray sphinx-gallery' + optional-packages: ' contextily geopandas ipython pyarrow-core rioxarray sphinx-gallery' # Python 3.12 + core packages (Linux only) - os: 'ubuntu-latest' python-version: '3.12'