Repository: geopandas/geopandas (Python)

Issue:
BUG: the clip function don't take dynamically the geometry column name  
Hi, today i noticed that the clip function didn't work for me but then i found which was the problem.

Import geodataframes with geometry called "WKT":
```
field_map = pd.read_csv('./field_map.csv')
field_map['WKT'] = field_map['WKT'].apply(wkt.loads)
field_map = gpd.GeoDataFrame(field_map, geometry = 'WKT', crs = {'init': 'epsg:4326'})

print(field_map.columns)

boundary_map = pd.read_csv('./boundary_map.csv')
boundary_map['WKT'] = boundary_map['WKT'].apply(wkt.loads)
boundary_map = gpd.GeoDataFrame(boundary_map, geometry = 'WKT', crs = {'init': 'epsg:4326'})

print(boundary_map.columns)

> Index(['Unnamed: 0', 'IDX', 'Value', 'WKT', 'WKTTypeID', 'IDXmaster'], dtype='object')
> Index(['Unnamed: 0', 'WKT'], dtype='object')

```
Clip the map and plot to validate:
```
clip_map = gpd.clip(field_map, boundary_map)

fig, ax = plt.subplots(figsize=(10,10))
clip_map.plot(ax=ax)
boundary_map.geometry.boundary.plot(ax=ax, color='red')
```
![image](https://user-images.githubusercontent.com/25191329/89591504-baa2b580-d820-11ea-84b0-3f5b41577ef2.png)

it seems that the clip has not worked but if we look at the of clip_map columns we see "WKT" and "geometry"

![image](https://user-images.githubusercontent.com/25191329/89591734-52080880-d821-11ea-8d30-ccb5f95e5f33.png)


**SOLUTION:**
This worked for me, renaming the geometry column as "geometry"

```
field_map = field_map.rename_geometry('geometry')
boundary_map = boundary_map.rename_geometry('geometry')

clip_map = gpd.clip(field_map, boundary_map)

fig, ax = plt.subplots(figsize=(10,10))
clip_map.plot(ax=ax)
boundary_map.geometry.boundary.plot(ax=ax, color='red')
```

![image](https://user-images.githubusercontent.com/25191329/89591886-ba56ea00-d821-11ea-8961-e39db3c8a4c1.png)

The clip function now work correctly
Regards




Discussion:
@wallystart Thanks for the report! Yes, `clip` should also work with differently named geometry columns. We probably missed a hard-coded "geometry" somewhere in the implementation.




> We probably missed a hard-coded "geometry" somewhere in the implementation.

Here
https://github.com/geopandas/geopandas/blob/0b804ea8afc9cf743643016048c65c8b07818af8/geopandas/tools/clip.py#L69



Patch:
diff --git a/geopandas/tools/clip.py b/geopandas/tools/clip.py
index 8a1d6d1e65..da76e0f21c 100644
--- a/geopandas/tools/clip.py
+++ b/geopandas/tools/clip.py
@@ -66,7 +66,7 @@ def _clip_line_poly(gdf, poly):
     # Clip the data with the polygon
     if isinstance(gdf_sub, GeoDataFrame):
         clipped = gdf_sub.copy()
-        clipped["geometry"] = gdf_sub.intersection(poly)
+        clipped[gdf.geometry.name] = gdf_sub.intersection(poly)
     else:
         # GeoSeries
         clipped = gdf_sub.intersection(poly)


Test patch:
diff --git a/geopandas/tools/tests/test_clip.py b/geopandas/tools/tests/test_clip.py
index 40abaa04c2..328bc92f64 100644
--- a/geopandas/tools/tests/test_clip.py
+++ b/geopandas/tools/tests/test_clip.py
@@ -203,6 +203,20 @@ def test_clip_points(point_gdf, single_rectangle_gdf):
     assert_geodataframe_equal(clip_pts, exp)
 
 
+def test_clip_points_geom_col_rename(point_gdf, single_rectangle_gdf):
+    """Test clipping a points GDF with a generic polygon geometry."""
+    point_gdf_geom_col_rename = point_gdf.rename_geometry("geometry2")
+    clip_pts = clip(point_gdf_geom_col_rename, single_rectangle_gdf)
+    pts = np.array([[2, 2], [3, 4], [9, 8]])
+    exp = GeoDataFrame(
+        [Point(xy) for xy in pts],
+        columns=["geometry2"],
+        crs="EPSG:4326",
+        geometry="geometry2",
+    )
+    assert_geodataframe_equal(clip_pts, exp)
+
+
 def test_clip_poly(buffered_locations, single_rectangle_gdf):
     """Test clipping a polygon GDF with a generic polygon geometry."""
     clipped_poly = clip(buffered_locations, single_rectangle_gdf)
@@ -210,6 +224,16 @@ def test_clip_poly(buffered_locations, single_rectangle_gdf):
     assert all(clipped_poly.geom_type == "Polygon")
 
 
+def test_clip_poly_geom_col_rename(buffered_locations, single_rectangle_gdf):
+    """Test clipping a polygon GDF with a generic polygon geometry."""
+
+    poly_gdf_geom_col_rename = buffered_locations.rename_geometry("geometry2")
+    clipped_poly = clip(poly_gdf_geom_col_rename, single_rectangle_gdf)
+    assert len(clipped_poly.geometry) == 3
+    assert "geometry" not in clipped_poly.keys()
+    assert "geometry2" in clipped_poly.keys()
+
+
 def test_clip_poly_series(buffered_locations, single_rectangle_gdf):
     """Test clipping a polygon GDF with a generic polygon geometry."""
     clipped_poly = clip(buffered_locations.geometry, single_rectangle_gdf)