internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: geopandas/geopandas

Issue:
BUG: CRS property is not pyproj.CRS object in empty GeoDataFrame
```python
import geopandas
import pyproj

df = geopandas.geodataframe.GeoDataFrame(crs='epsg:32638')
# this does not work in versions above 0.8.0
assert type(df.crs) is pyproj.crs.crs.CRS 

df.crs = 'epsg:32638'
# this works in both versions  0.8.0 and 0.7.0
assert type(df.crs) is pyproj.crs.crs.CRS 
```
Expected behavior: everything ok
Actual behavior: AssertionError

This is relevant for version above 0.8.0, for previous version 0.7.0 this code did not raise exception. In according with description for `crs` property return value should be  ``pyproj.CRS``object. As I understand was lost string `self.crs = crs` that invoked corresponded setter for parsing input string.


Discussion:
In 0.8 is CRS stored on GeometryArray level (primarily), so the fact that there is no geometry causes the issue. But your example should work, so this is a bug. Have you figured out a workaround?
Note that when doing the above, you get a deprecation warning about it (as @martinfleis mentioned, the crs is now stored on the array, so if there are no geometries, we can't properly store it, hence that is deprecated):

```
In [3]: df = geopandas.geodataframe.GeoDataFrame(crs='epsg:32638') 
<ipython-input-3-036a6818513a>:1: FutureWarning: Assigning CRS to a GeoDataFrame without a geometry column is now deprecated and will not be supported in the future.
```

---

I assume we should already convert the input to a pyproj.CRS even for the dummy one we keep in the GeoDataFrame constructor as workaround. 

Resolving patch:
diff --git a/geopandas/geodataframe.py b/geopandas/geodataframe.py
--- a/geopandas/geodataframe.py
+++ b/geopandas/geodataframe.py
@@ -90,7 +90,7 @@ def __init__(self, *args, **kwargs):
 
         # need to set this before calling self['geometry'], because
         # getitem accesses crs
-        self._crs = crs if crs is not None else None
+        self._crs = CRS.from_user_input(crs) if crs else None
 
         # set_geometry ensures the geometry data have the proper dtype,
         # but is not called if `geometry=None` ('geometry' column present


Test patch:
diff --git a/geopandas/tests/test_crs.py b/geopandas/tests/test_crs.py
--- a/geopandas/tests/test_crs.py
+++ b/geopandas/tests/test_crs.py
@@ -529,12 +529,18 @@ def test_merge(self):
     # CRS should be assigned to geometry
     def test_deprecation(self):
         with pytest.warns(FutureWarning):
-            GeoDataFrame([], crs=27700)
+            df = GeoDataFrame([], crs=27700)
+
+        # https://github.com/geopandas/geopandas/issues/1548
+        # ensure we still have converted the crs value to a CRS object
+        assert isinstance(df.crs, pyproj.CRS)
 
         with pytest.warns(FutureWarning):
             df = GeoDataFrame([])
             df.crs = 27700
 
+        assert isinstance(df.crs, pyproj.CRS)
+
     # make sure that geometry column from list has CRS (__setitem__)
     def test_setitem_geometry(self):
         arr = from_shapely(self.geoms, crs=27700)
Repository: geopandas/geopandas

Issue:
Logo
I think GeoPandas needs a logo, so I drew one:

![image](https://user-images.githubusercontent.com/41756119/43279837-c88c20b8-90d4-11e8-8b4e-9fd26cb1aabe.png)

It's all hand drawn, and all rights to it are hereby assigned to the GeoPandas maintainers.  logo.svg is the master source, but currently only the PNG-exported version is used.
Logo Proposal for GeoPandas
A great python package deserves a great logo! 


Discussion:
Thanks @BoBednar, I like the design!
https://github.com/geopandas/geopandas/pull/786

Resolving patch:
diff --git a/doc/source/conf.py b/doc/source/conf.py
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -166,12 +166,12 @@ def setup(app):
 
 # The name of an image file (relative to this directory) to place at the top
 # of the sidebar.
-html_logo = "_static/geopandas_logo.svg"
+html_logo = "_static/logo/geopandas_logo_web.svg"
 
 # The name of an image file (within the static path) to use as favicon of the
 # docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
 # pixels large.
-# html_favicon = None
+html_favicon = "_static/logo/favicon.png"
 
 # Add any paths that contain custom static files (such as style sheets) here,
 # relative to this directory. They are copied after the builtin static files,


Test patch:
Repository: geopandas/geopandas

Issue:
BUG: legend misplaced in subplots
I'm using v0.8.0. When I plot on multiple subplots and pass `legend_kwds` to `gdf.plot`, it draws all the subplot legends on the same subplot.

This works as expected:

```python
import geopandas as gpd
import matplotlib.pyplot as plt
gdf = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
fig, axes = plt.subplots(3, 2, figsize=(8,8))
for ax in axes.flat:
    gdf.plot(ax=ax, column='gdp_md_est', legend=True)
```
![1](https://user-images.githubusercontent.com/4977197/89090446-cccfb000-d357-11ea-8c9f-1505629b4f80.png)

But this draws the legends all on the same subplot:
```python
legend_kwds = {'orientation': 'horizontal'}
fig, axes = plt.subplots(3, 2, figsize=(8,8))
for ax in axes.flat:
    gdf.plot(ax=ax, column='gdp_md_est', legend=True, legend_kwds=legend_kwds)
```
![2](https://user-images.githubusercontent.com/4977197/89090447-ce997380-d357-11ea-9d86-7e5c6fb4edbf.png)

Is this user error or a bug?


Discussion:
It looks like a bug to me. I am just not sure if it is not a `matplotlib` bug, because we just pass `legend_kwds` to `colorbar`. 

Resolving patch:
diff --git a/geopandas/plotting.py b/geopandas/plotting.py
--- a/geopandas/plotting.py
+++ b/geopandas/plotting.py
@@ -600,6 +600,11 @@ def plot_dataframe(
     else:
         ax.set_aspect(aspect)
 
+    # GH 1555
+    # if legend_kwds set, copy so we don't update it in place
+    if legend_kwds is not None:
+        legend_kwds = legend_kwds.copy()
+
     if df.empty:
         warnings.warn(
             "The GeoDataFrame you are attempting to plot is "


Test patch:
Repository: geopandas/geopandas

Issue:
BUG: TypeError exception shows the type of the wrong variable
https://github.com/geopandas/geopandas/blob/b366d890c35d68a52f7f608e47f00b89eaa85850/geopandas/tools/clip.py#L130

This should reference 'mask' instead of 'gdf'.


Discussion:
That's correct, thanks for the notice! 
(and a pull request to fix it is always welcome)

Resolving patch:
diff --git a/geopandas/tools/clip.py b/geopandas/tools/clip.py
--- a/geopandas/tools/clip.py
+++ b/geopandas/tools/clip.py
@@ -127,7 +127,7 @@ def clip(gdf, mask, keep_geom_type=False):
     if not isinstance(mask, (GeoDataFrame, GeoSeries, Polygon, MultiPolygon)):
         raise TypeError(
             "'mask' should be GeoDataFrame, GeoSeries or"
-            "(Multi)Polygon, got {}".format(type(gdf))
+            "(Multi)Polygon, got {}".format(type(mask))
         )
 
     if isinstance(mask, (GeoDataFrame, GeoSeries)):


Test patch:
Repository: geopandas/geopandas

Issue:
Warning when missing_kwds provided but no areas missing data
If `df` is a GeoDataFrame which has no missing data in `column`, then if I do:

```
df.plot(column=column, 
        missing_kwds={'color': 'lightgrey'},
    )
```
...I get:

```
geopandas/plotting.py:332: UserWarning: The GeoSeries you are attempting to plot is empty. Nothing has been displayed.
```

`plot()` should, instead, just not attempt to plot the empty series when there's no missing data.

Workaround is to omit `missing_kwds` if you know there will be no missing data, but if you're unsure then you have to live with the warning as best I can tell?
Warning when missing_kwds provided but no areas missing data
If `df` is a GeoDataFrame which has no missing data in `column`, then if I do:

```
df.plot(column=column, 
        missing_kwds={'color': 'lightgrey'},
    )
```
...I get:

```
geopandas/plotting.py:332: UserWarning: The GeoSeries you are attempting to plot is empty. Nothing has been displayed.
```

`plot()` should, instead, just not attempt to plot the empty series when there's no missing data.

Workaround is to omit `missing_kwds` if you know there will be no missing data, but if you're unsure then you have to live with the warning as best I can tell?


Discussion:
Thanks! You are right, we should check if there are actually any geometries and do not try plot empty series in here:

https://github.com/geopandas/geopandas/blob/0b804ea8afc9cf743643016048c65c8b07818af8/geopandas/plotting.py#L752-L760

The one workaround could be to silence the warning.

```python
import warnings
warnings.filterwarnings("ignore", "The GeoSeries you are attempting", UserWarning)
```
Where would I look for existing test cases to add to for this?
Missing geometry tests are scattered around in `test_plotting.py`. I think we added them for each geometry types. 
Thanks! You are right, we should check if there are actually any geometries and do not try plot empty series in here:

https://github.com/geopandas/geopandas/blob/0b804ea8afc9cf743643016048c65c8b07818af8/geopandas/plotting.py#L752-L760

The one workaround could be to silence the warning.

```python
import warnings
warnings.filterwarnings("ignore", "The GeoSeries you are attempting", UserWarning)
```
Where would I look for existing test cases to add to for this?
Missing geometry tests are scattered around in `test_plotting.py`. I think we added them for each geometry types. 

Resolving patch:
diff --git a/geopandas/plotting.py b/geopandas/plotting.py
--- a/geopandas/plotting.py
+++ b/geopandas/plotting.py
@@ -754,7 +754,7 @@ def plot_dataframe(
             **style_kwds
         )
 
-    if missing_kwds is not None:
+    if missing_kwds is not None and not expl_series[nan_idx].empty:
         if color:
             if "color" not in missing_kwds:
                 missing_kwds["color"] = color


Test patch:
Repository: geopandas/geopandas

Issue:
BUG: rename_geometry should check if duplicate column name is created
Currently if you use the name of an existing column in `rename_geometry`, you get a bit confusing error message:

```python
>>> df = geopandas.read_file(geopandas.datasets.get_path("naturalearth_lowres"))

# this gives a not super helpful error message
>>> df.rename_geometry("continent")
...
TypeError: Input must be valid geometry objects: ['Oceania'
 <shapely.geometry.multipolygon.MultiPolygon object at 0x7fdf63d03be0>]

# this raises the same error, but in addition also leaves the df in a broken state
>>> df.rename_geometry("continent", inplace=True)
...
TypeError: Input must be valid geometry objects: ['Oceania'
 <shapely.geometry.multipolygon.MultiPolygon object at 0x7fdf633e6310>]

>>> df.geometry
...
AttributeError: No geometry data set yet (expected in column 'geometry'.)
```

(originally from https://github.com/CartoDB/cartoframes/issues/1517)


Discussion:
Would love to have a go at this 😺   
@Sangarshanan feel free to give it a go. Thanks!

Resolving patch:
diff --git a/geopandas/geodataframe.py b/geopandas/geodataframe.py
--- a/geopandas/geodataframe.py
+++ b/geopandas/geodataframe.py
@@ -289,10 +289,15 @@ def rename_geometry(self, col, inplace=False):
         geodataframe : GeoDataFrame
         """
         geometry_col = self.geometry.name
-        if not inplace:
-            return self.rename(columns={geometry_col: col}).set_geometry(col, inplace)
-        self.rename(columns={geometry_col: col}, inplace=inplace)
-        self.set_geometry(col, inplace=inplace)
+        if col in self.columns:
+            raise ValueError(f"Column named {col} already exists")
+        else:
+            if not inplace:
+                return self.rename(columns={geometry_col: col}).set_geometry(
+                    col, inplace
+                )
+            self.rename(columns={geometry_col: col}, inplace=inplace)
+            self.set_geometry(col, inplace=inplace)
 
     @property
     def crs(self):


Test patch:
diff --git a/geopandas/tests/test_geodataframe.py b/geopandas/tests/test_geodataframe.py
--- a/geopandas/tests/test_geodataframe.py
+++ b/geopandas/tests/test_geodataframe.py
@@ -209,6 +209,13 @@ def test_rename_geometry(self):
         assert df2 is None
         assert self.df.geometry.name == "new_name"
 
+        # existing column error
+        msg = "Column named Shape_Area already exists"
+        with pytest.raises(ValueError, match=msg):
+            df2 = self.df.rename_geometry("Shape_Area")
+        with pytest.raises(ValueError, match=msg):
+            self.df.rename_geometry("Shape_Area", inplace=True)
+
     def test_set_geometry(self):
         geom = GeoSeries([Point(x, y) for x, y in zip(range(5), range(5))])
         original_geom = self.df.geometry
Repository: geopandas/geopandas

Issue:
BUG: geom_type with pygeos master
Recent changes in pygeos master caused our tests to fail on `geom_type` checks for None.

https://github.com/geopandas/geopandas/runs/1171292789?check_suite_focus=true

For `None`, pygeos now returns Point instead of None as geometry type. I guess this needs to be fixed in pygeos but worth having an issue here to keep an eye on it. The reason is probably https://github.com/pygeos/pygeos/pull/199


Discussion:

Resolving patch:
diff --git a/geopandas/_vectorized.py b/geopandas/_vectorized.py
--- a/geopandas/_vectorized.py
+++ b/geopandas/_vectorized.py
@@ -38,7 +38,10 @@
 if compat.USE_PYGEOS:
     type_mapping = {p.value: _names[p.name] for p in pygeos.GeometryType}
     geometry_type_ids = list(type_mapping.keys())
-    geometry_type_values = np.array(list(type_mapping.values()), dtype=object)
+    geometry_type_ids.insert(0, -1)
+    type_mapping_list = list(type_mapping.values())
+    type_mapping_list.insert(0, None)
+    geometry_type_values = np.array(type_mapping_list, dtype=object)
 else:
     type_mapping, geometry_type_ids, geometry_type_values = None, None, None
 


Test patch:
Repository: geopandas/geopandas

Issue:
BUG: plotting MultiPoints with values-based coloring not working correctly
Example from the tests:

```
from shapely.affinity import rotate
from shapely.geometry import Point, MultiPoint

N = 10
points = GeoSeries(Point(i, i) for i in range(N))
multipoint1 = MultiPoint(points)
multipoint2 = rotate(multipoint1, 90)
df = GeoDataFrame(
    {"geometry": [multipoint1, multipoint2], "values": [0, 1]}
)
```

If you plot this where the colors get determined based on values (so not `df.plot(color="red")`, but eg `df.plot(column="values")` or `df.plot(cmap="viridis")`), the colors are incorrect. In this case they are all the same, but that will depend on the number of geometries / number of points in the multipoints. 


The reason for this is that the `values` for the color get "expanded" twice:

https://github.com/geopandas/geopandas/blob/9fdeb1474185c8d2edaede428f57d258810d87b7/geopandas/plotting.py#L256-L258

and then those values are set as the "c" in kwargs, and expanded again:

https://github.com/geopandas/geopandas/blob/9fdeb1474185c8d2edaede428f57d258810d87b7/geopandas/plotting.py#L263-L274






Discussion:

Resolving patch:
diff --git a/geopandas/plotting.py b/geopandas/plotting.py
--- a/geopandas/plotting.py
+++ b/geopandas/plotting.py
@@ -281,8 +281,7 @@ def _plot_point_collection(
         raise ValueError("Can only specify one of 'values' and 'color' kwargs")
 
     geoms, multiindex = _flatten_multi_geoms(geoms)
-    if values is not None:
-        values = np.take(values, multiindex, axis=0)
+    # values are expanded below as kwargs["c"]
 
     x = [p.x for p in geoms]
     y = [p.y for p in geoms]


Test patch:
diff --git a/geopandas/tests/test_plotting.py b/geopandas/tests/test_plotting.py
--- a/geopandas/tests/test_plotting.py
+++ b/geopandas/tests/test_plotting.py
@@ -314,13 +314,13 @@ def test_multipoints(self):
         _check_colors(4, ax.collections[0].get_facecolors(), [MPL_DFT_COLOR] * 4)
 
         ax = self.df2.plot(column="values")
-        cmap = plt.get_cmap()
+        cmap = plt.get_cmap(lut=2)
         expected_colors = [cmap(0)] * self.N + [cmap(1)] * self.N
-        _check_colors(2, ax.collections[0].get_facecolors(), expected_colors)
+        _check_colors(20, ax.collections[0].get_facecolors(), expected_colors)
 
         ax = self.df2.plot(color=["r", "b"])
         # colors are repeated for all components within a MultiPolygon
-        _check_colors(2, ax.collections[0].get_facecolors(), ["r"] * 10 + ["b"] * 10)
+        _check_colors(20, ax.collections[0].get_facecolors(), ["r"] * 10 + ["b"] * 10)
 
     def test_multipoints_alpha(self):
         ax = self.df2.plot(alpha=0.7)
Repository: geopandas/geopandas

Issue:
QST: Why no geometry/crs kwargs in GeoDataFrame.__init__?
- [X] I have searched the [geopandas] tag on [StackOverflow](https://stackoverflow.com/questions/tagged/geopandas) and [GIS StackExchange](https://gis.stackexchange.com/questions/tagged/geopandas) for similar questions.


---

#### Question about geopandas

The [`GeoDataFrame.__init__` method](https://github.com/geopandas/geopandas/blob/master/geopandas/geodataframe.py#L87) has no special keyword arguments in its signature. But the `geometry` and `crs` keywords are clearly important, and are `pop`ed out of `kwargs` right away.

```python
    def __init__(self, *args, **kwargs):
        crs = kwargs.pop("crs", None)
        geometry = kwargs.pop("geometry", None)
        ...
```

Is there a reason those special keyword args are not in the signature? i.e. why not this:
```python
    def __init__(self, *args, geometry=None, crs=None, **kwargs):
        ...
```


Discussion:
It looks that it evolved like this historically. There was a support of `crs` attribute before `crs` keyword - https://github.com/geopandas/geopandas/commit/64327aab8309deff00e384e242d0f6082d499632. I don't think this is a specific design decision, therefore there's no real reason why it looks as it looks. It is strange though that we document them separately but do not list them in the signature.

Feel free to push a PR changing that, I don't think it can cause any damage.

Resolving patch:
diff --git a/geopandas/geodataframe.py b/geopandas/geodataframe.py
--- a/geopandas/geodataframe.py
+++ b/geopandas/geodataframe.py
@@ -84,9 +84,7 @@ class GeoDataFrame(GeoPandasBase, DataFrame):
 
     _geometry_column_name = DEFAULT_GEO_COLUMN_NAME
 
-    def __init__(self, *args, **kwargs):
-        crs = kwargs.pop("crs", None)
-        geometry = kwargs.pop("geometry", None)
+    def __init__(self, *args, geometry=None, crs=None, **kwargs):
         with compat.ignore_shapely2_warnings():
             super(GeoDataFrame, self).__init__(*args, **kwargs)
 


Test patch:
Repository: geopandas/geopandas

Issue:
DOC: ReadTheDocs failure due to timeout
RTD does not seem to be happy about the switch to `nbsphinx` examples - https://readthedocs.org/projects/geopandas/builds/13052287/. 

Not sure why exactly, I can think of two reasons (it may actually be a combination of both).

1) I have removed pins from versions to get the recent version, that may take more time to resolve. I'll pin again to current versions tested locally.
2) We have more examples now, some may actually cause trouble/take time. Will explore.




Discussion:
Yes, the time to create the environment from the yml file went up from 324s (last passed build) to 534s in the failed build you linked. 
So that's 200s less available for actually building the docs. 
So I would start with pinning the versions again, that might be enough to get it passing.
We're now on 260s to create env but still timing out. 

Resolving patch:
diff --git a/doc/source/conf.py b/doc/source/conf.py
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -64,7 +64,6 @@ def setup(app):
 autosummary_generate = True
 
 nbsphinx_execute = "always"
-nbsphinx_kernel_name = "geopandas_docs"
 nbsphinx_allow_errors = True
 
 # connect docs in other projects


Test patch:
Repository: geopandas/geopandas

Issue:
CI: ERROR at setup of TestCasting.test_astype_string with pandas master
We have a failure with pandas master caused by https://github.com/pandas-dev/pandas/pull/40998. See the [CI log](https://github.com/geopandas/geopandas/runs/2484443872?check_suite_focus=true#step:6:2962).

It is one of the pandas extension tests we inherit and I am not sure if it should be fixed/skipped on our side or in pandas.

cc @jorisvandenbossche 

```py
_______________ ERROR at setup of TestCasting.test_astype_string _______________
[gw0] linux -- Python 3.8.8 /usr/share/miniconda/envs/test/bin/python
file /usr/share/miniconda/envs/test/lib/python3.8/site-packages/pandas/tests/extension/base/casting.py, line 46
      def test_astype_string(self, data, nullable_string_dtype):
E       fixture 'nullable_string_dtype' not found
>       available fixtures: add_geopandas, all_arithmetic_operators, all_boolean_reductions, all_compare_operators, all_data, all_numeric_reductions, as_array, as_frame, as_series, box_in_series, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, cov, data, data_for_grouping, data_for_sorting, data_for_twos, data_missing, data_missing_for_sorting, data_repeated, doctest_namespace, dtype, fillna_method, groupby_apply_op, monkeypatch, na_cmp, na_value, no_cover, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, testrun_uid, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory, use_numpy, worker_id
```


Discussion:
That's an error on pandas' side, it should not use fixtures defined outside of the extension tests. Will do a fix for that tomorrow. 
-> https://github.com/pandas-dev/pandas/pull/41278
That pandas fix resolved the initial error but the test is still failing on a different one - https://github.com/geopandas/geopandas/runs/2500242175?check_suite_focus=true#step:6:2964
Ah, now it's testing the actual code, and we have a proper failure. That will require both a change on pandas' and our side. Looking into it.

Resolving patch:
diff --git a/geopandas/array.py b/geopandas/array.py
--- a/geopandas/array.py
+++ b/geopandas/array.py
@@ -1030,7 +1030,7 @@ def astype(self, dtype, copy=True):
                 pd_dtype = pd.api.types.pandas_dtype(dtype)
                 if isinstance(pd_dtype, pd.StringDtype):
                     # ensure to return a pandas string array instead of numpy array
-                    return pd.array(string_values, dtype="string")
+                    return pd.array(string_values, dtype=pd_dtype)
             return string_values.astype(dtype, copy=False)
         else:
             return np.array(self, dtype=dtype, copy=copy)


Test patch: