Repository: corteva/geocube

Issue:
Deprecation warnings
https://travis-ci.com/github/corteva/geocube/jobs/415108723
```
test/integration/xarray_extensions/test_integration_xarray_extensions_vectorxarray.py::test_to_netcdf

  /home/travis/build/corteva/geocube/geocube/xarray_extensions/vectorxarray.py:59: PendingDeprecationWarning: dropping variables using `drop` will be deprecated; using drop_vars is encouraged.

    out_obj = self._obj.drop("crs")

test/integration/xarray_extensions/test_integration_xarray_extensions_vectorxarray.py::test_to_netcdf

  /home/travis/miniconda/envs/test/lib/python3.6/site-packages/numpy/core/_asarray.py:83: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray

    return array(a, dtype, copy=False, order=order)
```

Discussion:
codecov[bot]: # [Codecov](https://codecov.io/gh/corteva/geocube/pull/43?src=pr&el=h1) Report
> Merging [#43](https://codecov.io/gh/corteva/geocube/pull/43?src=pr&el=desc) (744f2b1) into [master](https://codecov.io/gh/corteva/geocube/commit/886a3265462f31399fd46c8f0ea2487f54fbecb0?el=desc) (886a326) will **increase** coverage by `0.04%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/corteva/geocube/pull/43/graphs/tree.svg?width=650&height=150&src=pr&token=LNGZQ7T61M)](https://codecov.io/gh/corteva/geocube/pull/43?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master      #43      +/-   ##
==========================================
+ Coverage   93.34%   93.39%   +0.04%     
==========================================
  Files          14       14              
  Lines         421      424       +3     
==========================================
+ Hits          393      396       +3     
  Misses         28       28              
```


| [Impacted Files](https://codecov.io/gh/corteva/geocube/pull/43?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [geocube/xarray\_extensions/vectorxarray.py](https://codecov.io/gh/corteva/geocube/pull/43/diff?src=pr&el=tree#diff-Z2VvY3ViZS94YXJyYXlfZXh0ZW5zaW9ucy92ZWN0b3J4YXJyYXkucHk=) | `97.77% <100.00%> (+0.15%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/corteva/geocube/pull/43?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/corteva/geocube/pull/43?src=pr&el=footer). Last update [886a326...744f2b1](https://codecov.io/gh/corteva/geocube/pull/43?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/.isort.cfg b/.isort.cfg
index 0f20555..b6e6d26 100644
--- a/.isort.cfg
+++ b/.isort.cfg
@@ -1,6 +1,6 @@
 [settings]
 line_length=88
 multi_line_output=3
-known_third_party=appdirs,click,datacube,dateutil,geopandas,mock,numpy,pandas,pyproj,pytest,rasterio,rioxarray,scipy,setuptools,shapely,xarray
+known_third_party=appdirs,click,datacube,dateutil,geopandas,mock,numpy,pandas,pytest,rasterio,rioxarray,scipy,setuptools,shapely,xarray
 known_first_party=geocube,test
 include_trailing_comma=true
diff --git a/geocube/xarray_extensions/vectorxarray.py b/geocube/xarray_extensions/vectorxarray.py
index 7a060f8..05da792 100644
--- a/geocube/xarray_extensions/vectorxarray.py
+++ b/geocube/xarray_extensions/vectorxarray.py
@@ -3,10 +3,14 @@
 This module is an extension for xarray to provide support for vector datasets.
 """
 import geopandas as gpd
+import numpy
+import rioxarray  # noqa: F401
 import xarray
-from pyproj import CRS
 from shapely.wkb import dumps, loads
 
+dumps_v = numpy.vectorize(dumps)
+loads_v = numpy.vectorize(loads)
+
 
 def from_geodataframe(in_geodataframe):
     """
@@ -14,8 +18,13 @@ def from_geodataframe(in_geodataframe):
     """
     geodf = in_geodataframe.copy().set_index("geometry")
     geox = xarray.Dataset.from_dataframe(geodf)
-    geox.coords["crs"] = 0
-    geox.coords["crs"].attrs["crs_wkt"] = CRS.from_user_input(geodf.crs).to_wkt()
+    # hack to get around dimension error when
+    # writing CRS
+    geox.rio._x_dim = "x"
+    geox.rio._y_dim = "y"
+    geox.rio.write_crs(geodf.crs, inplace=True)
+    geox.rio._x_dim = None
+    geox.rio._y_dim = None
     return geox
 
 
@@ -29,8 +38,7 @@ def open_dataset(*args, **kwargs):
 
     """
     xds = xarray.open_dataset(*args, **kwargs)
-    xds.coords["geometry"] = list(map(loads, xds.coords["geometry"].values))
-    return xds
+    return xds.assign_coords(geometry=loads_v(xds.coords["geometry"].values))
 
 
 class BaseVectorX:
@@ -56,21 +64,21 @@ class BaseVectorX:
 
         """
         self._validate_operation()
-        out_obj = self._obj.drop("crs")
+        out_obj = self._obj.drop_vars(self._obj.rio.grid_mapping)
         extra_coords = list(set(list(out_obj.coords)) - {"geometry"})
         if extra_coords:
             out_obj = out_obj.copy().reset_coords(extra_coords)
         geodf = gpd.GeoDataFrame(out_obj.to_dataframe().reset_index())
-        geodf.crs = self._obj.coords["crs"].attrs["crs_wkt"]
+        geodf.crs = self._obj.rio.crs
         return geodf
 
     def to_netcdf(self, *args, **kwargs):
         """
         Write the data to a netCDF file.
         """
-        out_obj = self._obj.copy()
-        out_obj.coords["geometry"] = list(map(dumps, out_obj.coords["geometry"].values))
-        out_obj.to_netcdf(*args, **kwargs)
+        self._obj.assign_coords(
+            geometry=dumps_v(self._obj.coords["geometry"].values)
+        ).to_netcdf(*args, **kwargs)
 
 
 @xarray.register_dataarray_accessor("vector")
diff --git a/setup.py b/setup.py
index 2d8b553..9a77229 100644
--- a/setup.py
+++ b/setup.py
@@ -14,7 +14,7 @@ requirements = [
     "appdirs",
     "Click>=6.0",
     "datacube",
-    "geopandas>=0.6",
+    "geopandas>=0.7",
     "rasterio",
     "rioxarray>=0.0.30",
     "xarray",


Test patch:
diff --git a/test/integration/xarray_extensions/test_integration_xarray_extensions_vectorxarray.py b/test/integration/xarray_extensions/test_integration_xarray_extensions_vectorxarray.py
index 6d84b9f..9aac54d 100644
--- a/test/integration/xarray_extensions/test_integration_xarray_extensions_vectorxarray.py
+++ b/test/integration/xarray_extensions/test_integration_xarray_extensions_vectorxarray.py
@@ -21,10 +21,10 @@ def test_from_geodataframe():
     gdf = gpd.read_file(os.path.join(TEST_INPUT_DATA_DIR, "soil_data_flat.geojson"))
     vxd = vectorxarray.from_geodataframe(gdf)
     assert all(gdf.geometry == vxd.geometry.values)
-    assert sorted(gdf.columns.tolist() + ["crs"]) == sorted(vxd.variables)
-    assert gdf.crs == vxd.crs.attrs["crs_wkt"]
+    assert sorted(gdf.columns.tolist() + ["spatial_ref"]) == sorted(vxd.variables)
+    assert gdf.crs == vxd.rio.crs
     assert "geometry" in vxd.coords
-    assert "crs" in vxd.coords
+    assert "spatial_ref" in vxd.coords
 
 
 def test_to_geodataframe():