Repository: geopandas/geopandas

Issue:
ENH: geopandas.GeoDataFrame.from_dict() could accept crs as parameter
Tested on version 0.8.1, the following command:

```
gpd.GeoDataFrame.from_dict(nodes, columns=["geometry"], orient="index", crs=32637)
```

Returns:

```
TypeError: from_dict() got an unexpected keyword argument 'crs'
```

Is this normal? It seems to me it should be able to accept it because `crs` is a typical GeoDataFrame parameter

Discussion:
johnflavin: Is there any difference between calling `GeoDataFrame.from_dict(...)` and `GeoDataFrame(...)`? I thought the latter could already take a dict.

If there is no difference, wouldn't the easier implementation of `from_dict(...)` be simply `return GeoDataFrame(...)`?

Patch:
diff --git a/doc/source/docs/user_guide/projections.rst b/doc/source/docs/user_guide/projections.rst
index 21d4fc78..4eb15309 100644
--- a/doc/source/docs/user_guide/projections.rst
+++ b/doc/source/docs/user_guide/projections.rst
@@ -240,7 +240,7 @@ For example, instead of:
 
    gdf.crs = "+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs"
 
-we recommenend to do:
+we recommend to do:
 
 .. code-block:: python
 
diff --git a/geopandas/geodataframe.py b/geopandas/geodataframe.py
index 507da60e..e18d40b4 100644
--- a/geopandas/geodataframe.py
+++ b/geopandas/geodataframe.py
@@ -397,6 +397,32 @@ class GeoDataFrame(GeoPandasBase, DataFrame):
         except Exception:
             pass
 
+    @classmethod
+    def from_dict(cls, data, geometry=None, crs=None, **kwargs):
+        """
+        Construct GeoDataFrame from dict of array-like or dicts by
+        overiding DataFrame.from_dict method with geometry and crs
+
+        Parameters
+        ----------
+        data : dict
+            Of the form {field : array-like} or {field : dict}.
+        geometry : str or array (optional)
+            If str, column to use as geometry. If array, will be set as 'geometry'
+            column on GeoDataFrame.
+        crs : str or dict (optional)
+            Coordinate reference system to set on the resulting frame.
+        kwargs : key-word arguments
+            These arguments are passed to DataFrame.from_dict
+
+        Returns
+        -------
+        GeoDataFrame
+
+        """
+        dataframe = super().from_dict(data, **kwargs)
+        return GeoDataFrame(dataframe, geometry=geometry, crs=crs)
+
     @classmethod
     def from_file(cls, filename, **kwargs):
         """Alternate constructor to create a ``GeoDataFrame`` from a file.
diff --git a/geopandas/plotting.py b/geopandas/plotting.py
index ddf6d2e7..c1765695 100644
--- 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_geodataframe.py b/geopandas/tests/test_geodataframe.py
index 4c6bc693..83b748f3 100644
--- a/geopandas/tests/test_geodataframe.py
+++ b/geopandas/tests/test_geodataframe.py
@@ -479,6 +479,16 @@ class TestDataFrame:
         assert_frame_equal(self.df2.loc[5:], self.df2.cx[:, 5:])
         assert_frame_equal(self.df2.loc[5:], self.df2.cx[5:, 5:])
 
+    def test_from_dict(self):
+        data = {"A": [1], "geometry": [Point(0.0, 0.0)]}
+        df = GeoDataFrame.from_dict(data, crs=3857)
+        assert df.crs == "epsg:3857"
+        assert df._geometry_column_name == "geometry"
+
+        data = {"B": [1], "location": [Point(0.0, 0.0)]}
+        df = GeoDataFrame.from_dict(data, geometry="location")
+        assert df._geometry_column_name == "location"
+
     def test_from_features(self):
         nybb_filename = geopandas.datasets.get_path("nybb")
         with fiona.open(nybb_filename) as f:
diff --git a/geopandas/tests/test_plotting.py b/geopandas/tests/test_plotting.py
index fe1eb27f..864ff2ad 100644
--- a/geopandas/tests/test_plotting.py
+++ b/geopandas/tests/test_plotting.py
@@ -314,13 +314,13 @@ class TestPointPlotting:
         _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)