[Git][debian-gis-team/python-geopandas][master] 4 commits: New upstream version 0.10.2

Bas Couwenberg (@sebastic) gitlab at salsa.debian.org
Sun Oct 17 06:53:10 BST 2021



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


Commits:
d50704c5 by Bas Couwenberg at 2021-10-17T07:41:24+02:00
New upstream version 0.10.2
- - - - -
4450f738 by Bas Couwenberg at 2021-10-17T07:41:54+02:00
Update upstream source from tag 'upstream/0.10.2'

Update to upstream version '0.10.2'
with Debian dir 29445acab31c46f5c8c9d1623b32553f1641155e
- - - - -
9e7ad814 by Bas Couwenberg at 2021-10-17T07:42:08+02:00
New upstream release.

- - - - -
02eae5b3 by Bas Couwenberg at 2021-10-17T07:43:07+02:00
Set distribution to unstable.

- - - - -


13 changed files:

- CHANGELOG.md
- debian/changelog
- doc/source/community/contributing.rst
- geopandas/_vectorized.py
- geopandas/_version.py
- geopandas/explore.py
- geopandas/plotting.py
- geopandas/tests/test_explore.py
- geopandas/tests/test_geom_methods.py
- geopandas/tests/test_overlay.py
- geopandas/tests/test_plotting.py
- geopandas/tools/clip.py
- geopandas/tools/overlay.py


Changes:

=====================================
CHANGELOG.md
=====================================
@@ -1,13 +1,33 @@
 Changelog
 =========
 
+Version 0.10.2 (October 16, 2021)
+---------------------------------
+
+Small bug-fix release:
+
+- Fix regression in `overlay()` in case no geometries are intersecting (but
+  have overlapping total bounds) (#2172).
+- Fix regression in `overlay()` with `keep_geom_type=True` in case the
+  overlay of two geometries in a GeometryCollection with other geometry types
+  (#2177).
+- Fix `overlay()` to honor the `keep_geom_type` keyword for the
+  `op="differnce"` case (#2164).
+- Fix regression in `plot()` with a mapclassify `scheme` in case the
+  formatted legend labels have duplicates (#2166).
+- Fix a bug in the `explore()` method ignoring the `vmin` and `vmax` keywords
+  in case they are set to 0 (#2175).
+- Fix `unary_union` to correctly handle a GeoSeries with missing values (#2181).
+- Avoid internal deprecation warning in `clip()` (#2179).
+
+
 Version 0.10.1 (October 8, 2021)
 --------------------------------
 
 Small bug-fix release:
 
 - Fix regression in `overlay()` with non-overlapping geometries and a
-  non-default `how` (.e. not "intersection") (#2157).
+  non-default `how` (i.e. not "intersection") (#2157).
 
 
 Version 0.10.0 (October 3, 2021)
@@ -86,7 +106,7 @@ Bug fixes:
 
 Notes on (optional) dependencies:
 
-- GeoPandas 0.9.0 dropped support for Python 3.6 and pandas 0.24. Further,
+- GeoPandas 0.10.0 dropped support for Python 3.6 and pandas 0.24. Further,
   the minimum required versions are numpy 1.18, shapely 1.6, fiona 1.8,
   matplotlib 3.1 and pyproj 2.2.
 - Plotting with a classification schema now requires mapclassify version >=


=====================================
debian/changelog
=====================================
@@ -1,3 +1,10 @@
+python-geopandas (0.10.2-1) unstable; urgency=medium
+
+  * Team upload.
+  * New upstream release.
+
+ -- Bas Couwenberg <sebastic at debian.org>  Sun, 17 Oct 2021 07:42:58 +0200
+
 python-geopandas (0.10.1-1) unstable; urgency=medium
 
   * Team upload.


=====================================
doc/source/community/contributing.rst
=====================================
@@ -82,7 +82,7 @@ Some great resources for learning Git:
 * Software Carpentry's `Git Tutorial <http://swcarpentry.github.io/git-novice/>`_
 * `Atlassian <https://www.atlassian.com/git/tutorials/what-is-version-control>`_
 * the `GitHub help pages <http://help.github.com/>`_.
-* Matthew Brett's `Pydagogue <http://matthew-brett.github.com/pydagogue/>`_.
+* Matthew Brett's `Pydagogue <https://matthew-brett.github.io/pydagogue/>`_.
 
 Getting started with Git
 ~~~~~~~~~~~~~~~~~~~~~~~~


=====================================
geopandas/_vectorized.py
=====================================
@@ -891,7 +891,11 @@ def unary_union(data):
     if compat.USE_PYGEOS:
         return _pygeos_to_shapely(pygeos.union_all(data))
     else:
-        return shapely.ops.unary_union(data)
+        data = [g for g in data if g is not None]
+        if data:
+            return shapely.ops.unary_union(data)
+        else:
+            return None
 
 
 #


=====================================
geopandas/_version.py
=====================================
@@ -22,8 +22,8 @@ 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 -> master, tag: v0.10.1)"
-    git_full = "f9e168181de34d3fdb6ea753a7b6d8467369da38"
+    git_refnames = " (HEAD -> master, tag: v0.10.2)"
+    git_full = "04d377f321972801888381356cb6259766eb63b6"
     keywords = {"refnames": git_refnames, "full": git_full}
     return keywords
 


=====================================
geopandas/explore.py
=====================================
@@ -396,8 +396,8 @@ GON (((180.00000 -16.06713, 180.00000...
             color = list(map(lambda x: cmap(x), df[column]))
 
         else:
-            vmin = gdf[column].min() if not vmin else vmin
-            vmax = gdf[column].max() if not vmax else vmax
+            vmin = gdf[column].min() if vmin is None else vmin
+            vmax = gdf[column].max() if vmax is None else vmax
 
             # get bins
             if scheme is not None:


=====================================
geopandas/plotting.py
=====================================
@@ -773,9 +773,11 @@ GON (((-122.84000 49.00000, -120.0000...
             if not show_interval:
                 labels = [c[1:-1] for c in labels]
 
-        values = pd.Categorical([np.nan] * len(values), categories=labels, ordered=True)
+        values = pd.Categorical(
+            [np.nan] * len(values), categories=binning.bins, ordered=True
+        )
         values[~nan_idx] = pd.Categorical.from_codes(
-            binning.yb, categories=labels, ordered=True
+            binning.yb, categories=binning.bins, ordered=True
         )
         if cmap is None:
             cmap = "viridis"
@@ -884,6 +886,8 @@ GON (((-122.84000 49.00000, -120.0000...
             norm = Normalize(vmin=mn, vmax=mx)
         n_cmap = cm.ScalarMappable(norm=norm, cmap=cmap)
         if categorical:
+            if scheme is not None:
+                categories = labels
             patches = []
             for value, cat in enumerate(categories):
                 patches.append(


=====================================
geopandas/tests/test_explore.py
=====================================
@@ -466,6 +466,20 @@ class TestExplore:
         assert 'case"119":return{"color":"#414287","fillColor":"#414287"' in out_str
         assert 'case"3":return{"color":"#482173","fillColor":"#482173"' in out_str
 
+        # test 0
+        df2 = self.nybb.copy()
+        df2["values"] = df2["BoroCode"] * 10.0
+        m = df2[df2["values"] >= 30].explore("values", vmin=0)
+        out_str = self._fetch_map_string(m)
+        assert 'case"1":return{"color":"#7ad151","fillColor":"#7ad151"' in out_str
+        assert 'case"2":return{"color":"#22a884","fillColor":"#22a884"' in out_str
+
+        df2["values_negative"] = df2["BoroCode"] * -10.0
+        m = df2[df2["values_negative"] <= 30].explore("values_negative", vmax=0)
+        out_str = self._fetch_map_string(m)
+        assert 'case"1":return{"color":"#414487","fillColor":"#414487"' in out_str
+        assert 'case"2":return{"color":"#2a788e","fillColor":"#2a788e"' in out_str
+
     def test_missing_vals(self):
         m = self.missing.explore("continent")
         assert '"fillColor":null' in self._fetch_map_string(m)


=====================================
geopandas/tests/test_geom_methods.py
=====================================
@@ -354,6 +354,12 @@ class TestGeomMethods:
 
         self._test_unary_topological("unary_union", expected, g)
 
+        g2 = GeoSeries([p1, None])
+        self._test_unary_topological("unary_union", p1, g2)
+
+        g3 = GeoSeries([None, None])
+        assert g3.unary_union is None
+
     def test_cascaded_union_deprecated(self):
         p1 = self.t1
         p2 = Polygon([(2, 0), (3, 0), (3, 1)])


=====================================
geopandas/tests/test_overlay.py
=====================================
@@ -628,6 +628,67 @@ def test_keep_geom_type_geometry_collection2():
     assert_geodataframe_equal(result1, expected1)
 
 
+def test_keep_geom_type_geomcoll_different_types():
+    polys1 = [box(0, 1, 1, 3), box(10, 10, 12, 12)]
+    polys2 = [
+        Polygon([(1, 0), (3, 0), (3, 3), (1, 3), (1, 2), (2, 2), (2, 1), (1, 1)]),
+        box(11, 11, 13, 13),
+    ]
+    df1 = GeoDataFrame({"left": [0, 1], "geometry": polys1})
+    df2 = GeoDataFrame({"right": [0, 1], "geometry": polys2})
+    result1 = overlay(df1, df2, keep_geom_type=True)
+    expected1 = GeoDataFrame(
+        {
+            "left": [1],
+            "right": [1],
+            "geometry": [box(11, 11, 12, 12)],
+        }
+    )
+    assert_geodataframe_equal(result1, expected1)
+
+    result2 = overlay(df1, df2, keep_geom_type=False)
+    expected2 = GeoDataFrame(
+        {
+            "left": [0, 1],
+            "right": [0, 1],
+            "geometry": [
+                GeometryCollection([LineString([(1, 2), (1, 3)]), Point(1, 1)]),
+                box(11, 11, 12, 12),
+            ],
+        }
+    )
+    assert_geodataframe_equal(result2, expected2)
+
+
+def test_keep_geom_type_geometry_collection_difference():
+    # GH 2163
+
+    polys1 = [
+        box(0, 0, 1, 1),
+        box(1, 1, 2, 2),
+    ]
+
+    # the tiny sliver in the second geometry may be converted to a
+    # linestring during the overlay process due to floating point errors
+    # on some platforms
+    polys2 = [
+        box(0, 0, 1, 1),
+        box(1, 1, 2, 3).union(box(2, 2, 3, 2.00000000000000001)),
+    ]
+    df1 = GeoDataFrame({"left": [0, 1], "geometry": polys1})
+    df2 = GeoDataFrame({"right": [0, 1], "geometry": polys2})
+
+    result1 = overlay(df2, df1, keep_geom_type=True, how="difference")
+    expected1 = GeoDataFrame(
+        {
+            "right": [1],
+            "geometry": [box(1, 2, 2, 3)],
+        },
+    )
+
+    assert_geodataframe_equal(result1, expected1)
+
+
 @pytest.mark.parametrize("make_valid", [True, False])
 def test_overlap_make_valid(make_valid):
     bowtie = Polygon([(1, 1), (9, 9), (9, 1), (1, 9), (1, 1)])
@@ -723,3 +784,14 @@ def test_non_overlapping(how):
         )
 
     assert_geodataframe_equal(result, expected)
+
+
+def test_no_intersection():
+    # overlapping bounds but non-overlapping geometries
+    gs = GeoSeries([Point(x, x).buffer(0.1) for x in range(3)])
+    gdf1 = GeoDataFrame({"foo": ["a", "b", "c"]}, geometry=gs)
+    gdf2 = GeoDataFrame({"bar": ["1", "3", "5"]}, geometry=gs.translate(1))
+
+    expected = GeoDataFrame(columns=["foo", "bar", "geometry"])
+    result = overlay(gdf1, gdf2, how="intersection")
+    assert_geodataframe_equal(result, expected, check_index_type=False)


=====================================
geopandas/tests/test_plotting.py
=====================================
@@ -1073,6 +1073,8 @@ class TestMapclassifyPlotting:
         cls.df["mid_vals"] = np.linspace(0.3, 0.7, cls.df.shape[0])
         cls.df["high_vals"] = np.linspace(0.7, 1.0, cls.df.shape[0])
         cls.df.loc[cls.df.index[:20:2], "high_vals"] = np.nan
+        cls.nybb = read_file(get_path("nybb"))
+        cls.nybb["vals"] = [0.001, 0.002, 0.003, 0.004, 0.005]
 
     def test_legend(self):
         with warnings.catch_warnings(record=True) as _:  # don't print warning
@@ -1333,6 +1335,35 @@ class TestMapclassifyPlotting:
             line.get_markerfacecolor() for line in ax3.get_legend().get_lines()
         ] == legend_colors_exp
 
+    def test_equally_formatted_bins(self):
+        ax = self.nybb.plot(
+            "vals",
+            scheme="quantiles",
+            legend=True,
+        )
+        labels = [t.get_text() for t in ax.get_legend().get_texts()]
+        expected = [
+            "0.00, 0.00",
+            "0.00, 0.00",
+            "0.00, 0.00",
+            "0.00, 0.00",
+            "0.00, 0.01",
+        ]
+        assert labels == expected
+
+        ax2 = self.nybb.plot(
+            "vals", scheme="quantiles", legend=True, legend_kwds=dict(fmt="{:.3f}")
+        )
+        labels = [t.get_text() for t in ax2.get_legend().get_texts()]
+        expected = [
+            "0.001, 0.002",
+            "0.002, 0.003",
+            "0.003, 0.003",
+            "0.003, 0.004",
+            "0.004, 0.005",
+        ]
+        assert labels == expected
+
 
 class TestPlotCollections:
     def setup_method(self):


=====================================
geopandas/tools/clip.py
=====================================
@@ -182,7 +182,7 @@ def clip(gdf, mask, keep_geom_type=False):
             elif new_collection or more_types:
                 orig_type = gdf.geom_type.iloc[0]
                 if new_collection:
-                    clipped = clipped.explode()
+                    clipped = clipped.explode(index_parts=False)
                 if orig_type in polys:
                     clipped = clipped.loc[clipped.geom_type.isin(polys)]
                 elif orig_type in lines:


=====================================
geopandas/tools/overlay.py
=====================================
@@ -65,6 +65,8 @@ def _overlay_intersection(df1, df2):
             right_index=True,
             suffixes=("_1", "_2"),
         )
+        result["__idx1"] = None
+        result["__idx2"] = None
         return result[
             result.columns.drop(df1.geometry.name).tolist() + [df1.geometry.name]
         ]
@@ -310,7 +312,7 @@ def overlay(df1, df2, how="intersection", keep_geom_type=None, make_valid=True):
     with warnings.catch_warnings():  # CRS checked above, suppress array-level warning
         warnings.filterwarnings("ignore", message="CRS mismatch between the CRS")
         if how == "difference":
-            return _overlay_difference(df1, df2)
+            result = _overlay_difference(df1, df2)
         elif how == "intersection":
             result = _overlay_intersection(df1, df2)
         elif how == "symmetric_difference":
@@ -321,6 +323,9 @@ def overlay(df1, df2, how="intersection", keep_geom_type=None, make_valid=True):
             dfunion = _overlay_union(df1, df2)
             result = dfunion[dfunion["__idx1"].notnull()].copy()
 
+        if how in ["intersection", "symmetric_difference", "union", "identity"]:
+            result.drop(["__idx1", "__idx2"], axis=1, inplace=True)
+
     if keep_geom_type:
         geom_type = df1.geom_type.iloc[0]
 
@@ -338,16 +343,18 @@ def overlay(df1, df2, how="intersection", keep_geom_type=None, make_valid=True):
 
             orig_num_geoms_exploded = exploded.shape[0]
             if geom_type in polys:
-                exploded = exploded.loc[exploded.geom_type.isin(polys)]
+                exploded.loc[~exploded.geom_type.isin(polys), geom_col] = None
             elif geom_type in lines:
-                exploded = exploded.loc[exploded.geom_type.isin(lines)]
+                exploded.loc[~exploded.geom_type.isin(lines), geom_col] = None
             elif geom_type in points:
-                exploded = exploded.loc[exploded.geom_type.isin(points)]
+                exploded.loc[~exploded.geom_type.isin(points), geom_col] = None
             else:
                 raise TypeError(
                     "`keep_geom_type` does not support {}.".format(geom_type)
                 )
-            num_dropped_collection = orig_num_geoms_exploded - exploded.shape[0]
+            num_dropped_collection = (
+                orig_num_geoms_exploded - exploded.geometry.isna().sum()
+            )
 
             # level_0 created with above reset_index operation
             # and represents the original geometry collections
@@ -385,5 +392,4 @@ def overlay(df1, df2, how="intersection", keep_geom_type=None, make_valid=True):
             )
 
     result.reset_index(drop=True, inplace=True)
-    result.drop(["__idx1", "__idx2"], axis=1, inplace=True)
     return result



View it on GitLab: https://salsa.debian.org/debian-gis-team/python-geopandas/-/compare/77612d87d036c52315ef2ff80f8edd5ad757be3a...02eae5b3bf3492c72db35318ffe1264b6651ff77

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/python-geopandas/-/compare/77612d87d036c52315ef2ff80f8edd5ad757be3a...02eae5b3bf3492c72db35318ffe1264b6651ff77
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/20211017/e1f32a11/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list