[Git][debian-gis-team/python-geopandas][upstream] New upstream version 0.12.2

Bas Couwenberg (@sebastic) gitlab at salsa.debian.org
Sun Dec 11 08:01:43 GMT 2022



Bas Couwenberg pushed to branch upstream at Debian GIS Project / python-geopandas


Commits:
8e3ad0e4 by Bas Couwenberg at 2022-12-11T08:44:42+01:00
New upstream version 0.12.2
- - - - -


15 changed files:

- CHANGELOG.md
- + doc/source/docs/changelog.md
- − doc/source/docs/changelog.rst
- doc/source/docs/user_guide/aggregation_with_dissolve.rst
- doc/source/docs/user_guide/mergingdata.rst
- doc/source/gallery/choropleths.ipynb
- geopandas/_vectorized.py
- geopandas/_version.py
- geopandas/datasets/naturalearth_creation.py
- geopandas/datasets/naturalearth_lowres/naturalearth_lowres.dbf
- geopandas/datasets/naturalearth_lowres/naturalearth_lowres.shp
- geopandas/datasets/naturalearth_lowres/naturalearth_lowres.shx
- geopandas/tests/test_crs.py
- geopandas/tests/test_sindex.py
- geopandas/tools/tests/test_clip.py


Changes:

=====================================
CHANGELOG.md
=====================================
@@ -1,23 +1,25 @@
-Changelog
-=========
+# Changelog
 
-Development version
--------------------
+## Version 0.12.2 (December 10, 2022)
 
-Version 0.12.1 (October 29, 2022)
----------------------------------
+Bug fixes:
+
+- Correctly handle geometries with Z dimension in ``to_crs()`` when using PyGEOS or
+  Shapely >= 2.0 (previously the z coordinates were lost) (#1345).
+- Assign Crimea to Ukraine in the ``naturalearth_lowres`` built-in dataset (#2670)
+
+## Version 0.12.1 (October 29, 2022)
 
 Small bug-fix release removing the shapely<2 pin in the installation requirements.
 
-Version 0.12 (October 24, 2022)
--------------------------------
+## Version 0.12 (October 24, 2022)
 
 The highlight of this release is the support for Shapely 2.0. This makes it possible to
 test Shapely 2.0 (currently 2.0b1) alongside GeoPandas.
 
 Note that if you also have PyGEOS installed, you need to set an environment variable
 (`USE_PYGEOS=0`) before importing geopandas to actually test Shapely 2.0 features instead of PyGEOS. See
-https://geopandas.org/en/latest/getting_started/install.html#using-the-optional-pygeos-dependency
+<https://geopandas.org/en/latest/getting_started/install.html#using-the-optional-pygeos-dependency>
 for more details.
 
 New features and improvements:
@@ -44,8 +46,7 @@ Bug fixes:
 - Combining GeoSeries/GeoDataFrames with ``pandas.concat`` will no longer silently
   override CRS information if not all inputs have the same CRS (#2056).
 
-Version 0.11.1 (July 24, 2022)
-------------------------------
+## Version 0.11.1 (July 24, 2022)
 
 Small bug-fix release:
 
@@ -54,8 +55,8 @@ Small bug-fix release:
   MultiIndex (#2486).
 - Fix regression in ``GeoDataFrame.explode()`` with non-default
   geometry column name.
-- Fix regression in ``apply()`` causing row-wise all nan float columns to be 
-  casted to GeometryDtype (#2482). 
+- Fix regression in ``apply()`` causing row-wise all nan float columns to be
+  casted to GeometryDtype (#2482).
 - Fix a crash in datetime column reading where the file contains mixed timezone
   offsets (#2479). These will be read as UTC localized values.
 - Fix a crash in datetime column reading where the file contains datetimes
@@ -67,9 +68,7 @@ Small bug-fix release:
   feather or parquet writer. ``version`` will only be used to set
   ``schema_version`` if ``version`` is one of 0.1.0 or 0.4.0 (#2496).
 
-
-Version 0.11 (June 20, 2022)
-----------------------------
+## Version 0.11.1 (July 24, 2022)
 
 Highlights of this release:
 


=====================================
doc/source/docs/changelog.md
=====================================
@@ -0,0 +1,2 @@
+``` {include} ../../../CHANGELOG.md
+```


=====================================
doc/source/docs/changelog.rst deleted
=====================================
@@ -1 +0,0 @@
-.. include:: ../../../CHANGELOG.md


=====================================
doc/source/docs/user_guide/aggregation_with_dissolve.rst
=====================================
@@ -95,5 +95,4 @@ and the ``'pop_est'`` column using ``'min'`` and ``'max'``:
             "pop_est": ["min", "max"],
         },
     )
-
    continents.head()


=====================================
doc/source/docs/user_guide/mergingdata.rst
=====================================
@@ -4,6 +4,7 @@
    :suppress:
 
    import geopandas
+   import pandas as pd
 
 
 Merging Data
@@ -43,12 +44,12 @@ Keep in mind, that appended geometry columns needs to have the same CRS.
 .. ipython:: python
 
     # Appending GeoSeries
-    joined = world.geometry.append(cities.geometry)
+    joined = pd.concat([world.geometry, cities.geometry])
 
     # Appending GeoDataFrames
     europe = world[world.continent == 'Europe']
     asia = world[world.continent == 'Asia']
-    eurasia = europe.append(asia)
+    eurasia = pd.concat([europe, asia])
 
 
 Attribute Joins


=====================================
doc/source/gallery/choropleths.ipynb
=====================================
The diff for this file was not included because it is too large.

=====================================
geopandas/_vectorized.py
=====================================
@@ -1096,15 +1096,24 @@ def bounds(data):
 
 
 def transform(data, func):
-    if compat.USE_SHAPELY_20:
-        coords = shapely.get_coordinates(data)
-        new_coords = func(coords[:, 0], coords[:, 1])
-        result = shapely.set_coordinates(data.copy(), np.array(new_coords).T)
-        return result
-    if compat.USE_PYGEOS:
-        coords = pygeos.get_coordinates(data)
-        new_coords = func(coords[:, 0], coords[:, 1])
-        result = pygeos.set_coordinates(data.copy(), np.array(new_coords).T)
+    if compat.USE_SHAPELY_20 or compat.USE_PYGEOS:
+        if compat.USE_SHAPELY_20:
+            has_z = shapely.has_z(data)
+            from shapely import get_coordinates, set_coordinates
+        else:
+            has_z = pygeos.has_z(data)
+            from pygeos import get_coordinates, set_coordinates
+
+        result = np.empty_like(data)
+
+        coords = get_coordinates(data[~has_z], include_z=False)
+        new_coords_z = func(coords[:, 0], coords[:, 1])
+        result[~has_z] = set_coordinates(data[~has_z].copy(), np.array(new_coords_z).T)
+
+        coords_z = get_coordinates(data[has_z], include_z=True)
+        new_coords_z = func(coords_z[:, 0], coords_z[:, 1], coords_z[:, 2])
+        result[has_z] = set_coordinates(data[has_z].copy(), np.array(new_coords_z).T)
+
         return result
     else:
         from shapely.ops import transform


=====================================
geopandas/_version.py
=====================================
@@ -23,9 +23,9 @@ def get_keywords():
     # setup.py/versioneer.py will grep for the variable names, so they must
     # each be defined on a line of their own. _version.py will just call
     # get_keywords().
-    git_refnames = " (HEAD -> main, tag: v0.12.1)"
-    git_full = "195f70bd1aef5f4eea014b4947e067723ceb6d92"
-    git_date = "2022-10-29 09:25:27 +0200"
+    git_refnames = " (tag: v0.12.2, v0.12.x)"
+    git_full = "efcb3675d94935ee19b06c75467f9ccc24eb8843"
+    git_date = "2022-12-10 19:37:18 +0100"
     keywords = {"refnames": git_refnames, "full": git_full, "date": git_date}
     return keywords
 


=====================================
geopandas/datasets/naturalearth_creation.py
=====================================
@@ -11,6 +11,7 @@ import requests
 from pathlib import Path
 from zipfile import ZipFile
 import tempfile
+from shapely.geometry import box
 
 version = "latest"
 urlbase = "https://www.naturalearthdata.com/"
@@ -89,6 +90,29 @@ for dl in config:
             gdf = dl["override"](gdf)
         gdf = gdf.loc[:, dl["cols"]]
         gdf = gdf.rename(columns={c: c.lower() for c in gdf.columns})
+
+        # override Crimea #2382
+        if dl["file"] == "ne_110m_admin_0_countries.zip":
+            crimean_bbox = box(32.274, 44.139, 36.65, 46.704)
+            crimea_only = (
+                gdf.loc[gdf.name == "Russia", "geometry"]
+                .iloc[0]
+                .intersection(crimean_bbox)
+            )
+            complete_ukraine = (
+                gdf.loc[gdf.name == "Ukraine", "geometry"].iloc[0].union(crimea_only)
+            )
+            correct_russia = (
+                gdf.loc[gdf.name == "Russia", "geometry"]
+                .iloc[0]
+                .difference(crimean_bbox)
+            )
+            r_ix = gdf.loc[gdf.name == "Russia"].index[0]
+            gdf.at[r_ix, "geometry"] = correct_russia
+
+            u_ix = gdf.loc[gdf.name == "Ukraine"].index[0]
+            gdf.at[u_ix, "geometry"] = complete_ukraine
+
         # get changes between current version and new version
         if not df_same(gdf, gpd.read_file(dl["current"]), dl["file"], log):
             downloads[dl["file"]] = gdf


=====================================
geopandas/datasets/naturalearth_lowres/naturalearth_lowres.dbf
=====================================
Binary files a/geopandas/datasets/naturalearth_lowres/naturalearth_lowres.dbf and b/geopandas/datasets/naturalearth_lowres/naturalearth_lowres.dbf differ


=====================================
geopandas/datasets/naturalearth_lowres/naturalearth_lowres.shp
=====================================
Binary files a/geopandas/datasets/naturalearth_lowres/naturalearth_lowres.shp and b/geopandas/datasets/naturalearth_lowres/naturalearth_lowres.shp differ


=====================================
geopandas/datasets/naturalearth_lowres/naturalearth_lowres.shx
=====================================
Binary files a/geopandas/datasets/naturalearth_lowres/naturalearth_lowres.shx and b/geopandas/datasets/naturalearth_lowres/naturalearth_lowres.shx differ


=====================================
geopandas/tests/test_crs.py
=====================================
@@ -58,6 +58,13 @@ def test_to_crs_transform__missing_data():
     assert_geodataframe_equal(df, utm, check_less_precise=True)
 
 
+def test_to_crs_transform__empty_data():
+    df = df_epsg26918().iloc[:0]
+    lonlat = df.to_crs(epsg=4326)
+    utm = lonlat.to_crs(epsg=26918)
+    assert_geodataframe_equal(df, utm, check_less_precise=True)
+
+
 def test_to_crs_inplace():
     df = df_epsg26918()
     lonlat = df.to_crs(epsg=4326)
@@ -77,6 +84,26 @@ def test_to_crs_geo_column_name():
     assert_geodataframe_equal(df, utm, check_less_precise=True)
 
 
+def test_to_crs_dimension_z():
+    # preserve z dimension
+    arr = points_from_xy([1, 2], [2, 3], [3, 4], crs=4326)
+    assert arr.has_z.all()
+    result = arr.to_crs(epsg=3857)
+    assert result.has_z.all()
+
+
+def test_to_crs_dimension_mixed():
+    s = GeoSeries([Point(1, 2), LineString([(1, 2, 3), (4, 5, 6)])], crs=2056)
+    result = s.to_crs(epsg=4326)
+    assert not result[0].is_empty
+    assert result.has_z.tolist() == [False, True]
+    roundtrip = result.to_crs(epsg=2056)
+    # TODO replace with assert_geoseries_equal once we expose tolerance keyword
+    # assert_geoseries_equal(roundtrip, s, check_less_precise=True)
+    for a, b in zip(roundtrip, s):
+        np.testing.assert_allclose(a.coords[:], b.coords[:], atol=0.01)
+
+
 # -----------------------------------------------------------------------------
 # Test different supported formats for CRS specification
 


=====================================
geopandas/tests/test_sindex.py
=====================================
@@ -861,7 +861,7 @@ class TestPygeosInterface:
     @pytest.mark.parametrize(
         "predicate, expected_shape",
         [
-            (None, (2, 470)),
+            (None, (2, 471)),
             ("intersects", (2, 213)),
             ("within", (2, 213)),
             ("contains", (2, 0)),


=====================================
geopandas/tools/tests/test_clip.py
=====================================
@@ -176,7 +176,7 @@ def multi_point(point_gdf):
 @pytest.fixture
 def mixed_gdf():
     """Create a Mixed Polygon and LineString For Testing"""
-    point = Point([(2, 3), (11, 4), (7, 2), (8, 9), (1, 13)])
+    point = Point(2, 3)
     line = LineString([(1, 1), (2, 2), (3, 2), (5, 3), (12, 1)])
     poly = Polygon([(3, 4), (5, 2), (12, 2), (10, 5), (9, 7.5)])
     ring = LinearRing([(1, 1), (2, 2), (3, 2), (5, 3), (12, 1)])
@@ -189,7 +189,7 @@ def mixed_gdf():
 @pytest.fixture
 def geomcol_gdf():
     """Create a Mixed Polygon and LineString For Testing"""
-    point = Point([(2, 3), (11, 4), (7, 2), (8, 9), (1, 13)])
+    point = Point(2, 3)
     poly = Polygon([(3, 4), (5, 2), (12, 2), (10, 5), (9, 7.5)])
     coll = GeometryCollection([point, poly])
     gdf = GeoDataFrame([1], geometry=[coll], crs="EPSG:3857")



View it on GitLab: https://salsa.debian.org/debian-gis-team/python-geopandas/-/commit/8e3ad0e44c192155c69093872d3053b73908b2e0

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/python-geopandas/-/commit/8e3ad0e44c192155c69093872d3053b73908b2e0
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20221211/c46f1f8d/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list