From 76ef46a82a2aba246bb33fa0f1337d4ccc04387f Mon Sep 17 00:00:00 2001 From: Martin Fleischmann Date: Mon, 22 Apr 2024 20:39:36 +0200 Subject: [PATCH 1/3] implement __repr__ showing geoms --- xvec/index.py | 16 ++++++++++++++++ xvec/tests/test_index.py | 21 +++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/xvec/index.py b/xvec/index.py index b262e71..c10c83d 100644 --- a/xvec/index.py +++ b/xvec/index.py @@ -273,3 +273,19 @@ def _repr_inline_(self, max_width: int) -> str: srs = _format_crs(self.crs, max_width=max_width) return f"{self.__class__.__name__} (crs={srs})" + + def __repr__(self) -> str: + srs = _format_crs(self.crs) + shape = self._index.index.shape[0] + if shape < 10: + wkts = [repr(g) for g in self._index.index] + else: + wkts = [repr(g) for g in self._index.index[:4]] + wkts.append("...") + wkts = wkts + [repr(g) for g in self._index.index[-4:]] + + if len(wkts) == 1: + return f"GeometryIndex([{wkts[0]}], crs={srs})" + return f"GeometryIndex(\n[{wkts[0]}\n {'\n '.join(wkts[1:])}],\ncrs={srs})".replace( + "\n", "\n" + " " * 4 + ) diff --git a/xvec/tests/test_index.py b/xvec/tests/test_index.py index f61dad2..a4d0cd1 100644 --- a/xvec/tests/test_index.py +++ b/xvec/tests/test_index.py @@ -172,3 +172,24 @@ def test_repr_inline(geom_dataset, geom_dataset_no_crs): actual = geom_dataset_no_crs.xindexes["geom"]._repr_inline_(70) expected = "GeometryIndex (crs=None)" assert actual == expected + + +def test_repr(geom_dataset, geom_dataset_no_crs): + actual = repr(geom_dataset.xindexes["geom"]) + expected = ( + "GeometryIndex(\n [\n ],\n crs=EPSG:26915)" + ) + assert actual == expected + + actual = repr(geom_dataset_no_crs.xindexes["geom"]) + expected = "GeometryIndex(\n [\n ],\n crs=None)" + assert actual == expected + + single = geom_dataset.sel(geom=[shapely.Point(1, 2)]) + actual = repr(single.xindexes["geom"]) + expected = "GeometryIndex([], crs=EPSG:26915)" + assert actual == expected + + long = xr.concat([geom_dataset] * 10, dim="geom") + actual = repr(long.xindexes["geom"]) + expected = "GeometryIndex(\n [\n \n \n \n ...\n \n \n \n ],\n crs=EPSG:26915)" From ca8959e8709cbb0903e5d6a5c040b3e27419da96 Mon Sep 17 00:00:00 2001 From: Martin Fleischmann Date: Mon, 22 Apr 2024 20:42:31 +0200 Subject: [PATCH 2/3] execute notebooks --- doc/source/extract_pts.ipynb | 114 ++++++--- doc/source/geopandas.ipynb | 142 ++++++----- doc/source/indexing.ipynb | 313 ++++++++++++++++-------- doc/source/intro.ipynb | 44 +++- doc/source/io.ipynb | 164 +++++++++---- doc/source/projections.ipynb | 158 ++++++++---- doc/source/zonal_stats.ipynb | 458 ++++++++++++++++++----------------- 7 files changed, 871 insertions(+), 522 deletions(-) diff --git a/doc/source/extract_pts.ipynb b/doc/source/extract_pts.ipynb index 599d6e3..17e0205 100644 --- a/doc/source/extract_pts.ipynb +++ b/doc/source/extract_pts.ipynb @@ -421,18 +421,18 @@ " v (month, level, latitude, longitude) float64 ...\n", "Attributes:\n", " Conventions: CF-1.0\n", - " Info: Monthly ERA-Interim data. Downloaded and edited by fabien.m...
  • Conventions :
    CF-1.0
    Info :
    Monthly ERA-Interim data. Downloaded and edited by fabien.maussion@uibk.ac.at
  • " ], "text/plain": [ "\n", @@ -899,10 +899,20 @@ " geometry GeometryIndex (crs=None)\n", "Attributes:\n", " Conventions: CF-1.0\n", - " Info: Monthly ERA-Interim data. Downloaded and edited by fabien.m...
    • z
      (month, level, geometry)
      float64
      ...
      number_of_significant_digits :
      5
      units :
      m**2 s**-2
      long_name :
      Geopotential
      standard_name :
      geopotential
      [60 values with dtype=float64]
    • u
      (month, level, geometry)
      float64
      ...
      number_of_significant_digits :
      2
      units :
      m s**-1
      long_name :
      U component of wind
      standard_name :
      eastward_wind
      [60 values with dtype=float64]
    • v
      (month, level, geometry)
      float64
      ...
      number_of_significant_digits :
      2
      units :
      m s**-1
      long_name :
      V component of wind
      standard_name :
      northward_wind
      [60 values with dtype=float64]
    • level
      PandasIndex
      PandasIndex(Index([200, 500, 850], dtype='int32', name='level'))
    • month
      PandasIndex
      PandasIndex(Index([1, 7], dtype='int32', name='month'))
    • geometry
      GeometryIndex (crs=None)
      GeometryIndex(\n",
      +       "    [<POINT (-180 -90)>\n",
      +       "     <POINT (-140.083 -70)>\n",
      +       "     <POINT (-100.167 -50)>\n",
      +       "     <POINT (-60.25 -30)>\n",
      +       "     ...\n",
      +       "     <POINT (59.5 30)>\n",
      +       "     <POINT (99.417 50)>\n",
      +       "     <POINT (139.333 70)>\n",
      +       "     <POINT (179.25 90)>],\n",
      +       "    crs=None)
  • Conventions :
    CF-1.0
    Info :
    Monthly ERA-Interim data. Downloaded and edited by fabien.maussion@uibk.ac.at
  • " ], "text/plain": [ "\n", @@ -1362,10 +1372,20 @@ " geometry GeometryIndex (crs=EPSG:4326)\n", "Attributes:\n", " Conventions: CF-1.0\n", - " Info: Monthly ERA-Interim data. Downloaded and edited by fabien.m...
    • z
      (month, level, geometry)
      float64
      ...
      number_of_significant_digits :
      5
      units :
      m**2 s**-2
      long_name :
      Geopotential
      standard_name :
      geopotential
      [60 values with dtype=float64]
    • u
      (month, level, geometry)
      float64
      ...
      number_of_significant_digits :
      2
      units :
      m s**-1
      long_name :
      U component of wind
      standard_name :
      eastward_wind
      [60 values with dtype=float64]
    • v
      (month, level, geometry)
      float64
      ...
      number_of_significant_digits :
      2
      units :
      m s**-1
      long_name :
      V component of wind
      standard_name :
      northward_wind
      [60 values with dtype=float64]
    • level
      PandasIndex
      PandasIndex(Index([200, 500, 850], dtype='int32', name='level'))
    • month
      PandasIndex
      PandasIndex(Index([1, 7], dtype='int32', name='month'))
    • geometry
      GeometryIndex (crs=EPSG:4326)
      GeometryIndex(\n",
      +       "    [<POINT (-180 -90)>\n",
      +       "     <POINT (-140.083 -70)>\n",
      +       "     <POINT (-100.167 -50)>\n",
      +       "     <POINT (-60.25 -30)>\n",
      +       "     ...\n",
      +       "     <POINT (59.5 30)>\n",
      +       "     <POINT (99.417 50)>\n",
      +       "     <POINT (139.333 70)>\n",
      +       "     <POINT (179.25 90)>],\n",
      +       "    crs=EPSG:4326)
  • Conventions :
    CF-1.0
    Info :
    Monthly ERA-Interim data. Downloaded and edited by fabien.maussion@uibk.ac.at
  • " ], "text/plain": [ "\n", @@ -1451,16 +1471,16 @@ { "data": { "text/plain": [ - "0 POINT (-180.00000 -90.00000)\n", - "1 POINT (-140.08333 -70.00000)\n", - "2 POINT (-100.16667 -50.00000)\n", - "3 POINT (-60.25000 -30.00000)\n", - "4 POINT (-20.33333 -10.00000)\n", - "5 POINT (19.58333 10.00000)\n", - "6 POINT (59.50000 30.00000)\n", - "7 POINT (99.41667 50.00000)\n", - "8 POINT (139.33333 70.00000)\n", - "9 POINT (179.25000 90.00000)\n", + "0 POINT (-180 -90)\n", + "1 POINT (-140.08333 -70)\n", + "2 POINT (-100.16667 -50)\n", + "3 POINT (-60.25 -30)\n", + "4 POINT (-20.33333 -10)\n", + "5 POINT (19.58333 10)\n", + "6 POINT (59.5 30)\n", + "7 POINT (99.41667 50)\n", + "8 POINT (139.33333 70)\n", + "9 POINT (179.25 90)\n", "dtype: geometry" ] }, @@ -1862,10 +1882,20 @@ " geometry GeometryIndex (crs=EPSG:4326)\n", "Attributes:\n", " Conventions: CF-1.0\n", - " Info: Monthly ERA-Interim data. Downloaded and edited by fabien.m...
    • z
      (month, level, geometry)
      float64
      ...
      number_of_significant_digits :
      5
      units :
      m**2 s**-2
      long_name :
      Geopotential
      standard_name :
      geopotential
      [60 values with dtype=float64]
    • u
      (month, level, geometry)
      float64
      ...
      number_of_significant_digits :
      2
      units :
      m s**-1
      long_name :
      U component of wind
      standard_name :
      eastward_wind
      [60 values with dtype=float64]
    • v
      (month, level, geometry)
      float64
      ...
      number_of_significant_digits :
      2
      units :
      m s**-1
      long_name :
      V component of wind
      standard_name :
      northward_wind
      [60 values with dtype=float64]
    • level
      PandasIndex
      PandasIndex(Index([200, 500, 850], dtype='int32', name='level'))
    • month
      PandasIndex
      PandasIndex(Index([1, 7], dtype='int32', name='month'))
    • geometry
      GeometryIndex (crs=EPSG:4326)
      GeometryIndex(\n",
      +       "    [<POINT (-180 -90)>\n",
      +       "     <POINT (-140.083 -70)>\n",
      +       "     <POINT (-100.167 -50)>\n",
      +       "     <POINT (-60.25 -30)>\n",
      +       "     ...\n",
      +       "     <POINT (59.5 30)>\n",
      +       "     <POINT (99.417 50)>\n",
      +       "     <POINT (139.333 70)>\n",
      +       "     <POINT (179.25 90)>],\n",
      +       "    crs=EPSG:4326)
  • Conventions :
    CF-1.0
    Info :
    Monthly ERA-Interim data. Downloaded and edited by fabien.maussion@uibk.ac.at
  • " ], "text/plain": [ "\n", @@ -2290,10 +2320,20 @@ " geometry GeometryIndex (crs=EPSG:4326)\n", "Attributes:\n", " Conventions: CF-1.0\n", - " Info: Monthly ERA-Interim data. Downloaded and edited by fabien.m...
    • z
      (month, level, geometry)
      float64
      ...
      number_of_significant_digits :
      5
      units :
      m**2 s**-2
      long_name :
      Geopotential
      standard_name :
      geopotential
      [60 values with dtype=float64]
    • u
      (month, level, geometry)
      float64
      ...
      number_of_significant_digits :
      2
      units :
      m s**-1
      long_name :
      U component of wind
      standard_name :
      eastward_wind
      [60 values with dtype=float64]
    • v
      (month, level, geometry)
      float64
      ...
      number_of_significant_digits :
      2
      units :
      m s**-1
      long_name :
      V component of wind
      standard_name :
      northward_wind
      [60 values with dtype=float64]
    • level
      PandasIndex
      PandasIndex(Index([200, 500, 850], dtype='int32', name='level'))
    • month
      PandasIndex
      PandasIndex(Index([1, 7], dtype='int32', name='month'))
    • geometry
      GeometryIndex (crs=EPSG:4326)
      GeometryIndex(\n",
      +       "    [<POINT (-180 -90)>\n",
      +       "     <POINT (-140.083 -70)>\n",
      +       "     <POINT (-100.167 -50)>\n",
      +       "     <POINT (-60.25 -30)>\n",
      +       "     ...\n",
      +       "     <POINT (59.5 30)>\n",
      +       "     <POINT (99.417 50)>\n",
      +       "     <POINT (139.333 70)>\n",
      +       "     <POINT (179.25 90)>],\n",
      +       "    crs=EPSG:4326)
  • Conventions :
    CF-1.0
    Info :
    Monthly ERA-Interim data. Downloaded and edited by fabien.maussion@uibk.ac.at
  • " ], "text/plain": [ "\n", @@ -2721,13 +2761,23 @@ "Indexes:\n", " geometry GeometryIndex (crs=EPSG:4326)\n", "Attributes:\n", - " crs: EPSG:4326
    • geometry
      GeometryIndex (crs=EPSG:4326)
      GeometryIndex(\n",
      +       "    [<POINT (-180 -90)>\n",
      +       "     <POINT (-140.083 -70)>\n",
      +       "     <POINT (-100.167 -50)>\n",
      +       "     <POINT (-60.25 -30)>\n",
      +       "     ...\n",
      +       "     <POINT (59.5 30)>\n",
      +       "     <POINT (99.417 50)>\n",
      +       "     <POINT (139.333 70)>\n",
      +       "     <POINT (179.25 90)>],\n",
      +       "    crs=EPSG:4326)
  • crs :
    EPSG:4326
  • " ], "text/plain": [ "\n", @@ -3150,10 +3200,20 @@ " geometry GeometryIndex (crs=EPSG:4326)\n", "Attributes:\n", " Conventions: CF-1.0\n", - " Info: Monthly ERA-Interim data. Downloaded and edited by fabien.m...
    • z
      (month, level, geometry)
      float64
      ...
      number_of_significant_digits :
      5
      units :
      m**2 s**-2
      long_name :
      Geopotential
      standard_name :
      geopotential
      [60 values with dtype=float64]
    • u
      (month, level, geometry)
      float64
      ...
      number_of_significant_digits :
      2
      units :
      m s**-1
      long_name :
      U component of wind
      standard_name :
      eastward_wind
      [60 values with dtype=float64]
    • v
      (month, level, geometry)
      float64
      ...
      number_of_significant_digits :
      2
      units :
      m s**-1
      long_name :
      V component of wind
      standard_name :
      northward_wind
      [60 values with dtype=float64]
    • level
      PandasIndex
      PandasIndex(Index([200, 500, 850], dtype='int32', name='level'))
    • month
      PandasIndex
      PandasIndex(Index([1, 7], dtype='int32', name='month'))
    • geometry
      GeometryIndex (crs=EPSG:4326)
      GeometryIndex(\n",
      +       "    [<POINT (-180 -90)>\n",
      +       "     <POINT (-140.083 -70)>\n",
      +       "     <POINT (-100.167 -50)>\n",
      +       "     <POINT (-60.25 -30)>\n",
      +       "     ...\n",
      +       "     <POINT (59.5 30)>\n",
      +       "     <POINT (99.417 50)>\n",
      +       "     <POINT (139.333 70)>\n",
      +       "     <POINT (179.25 90)>],\n",
      +       "    crs=EPSG:4326)
  • Conventions :
    CF-1.0
    Info :
    Monthly ERA-Interim data. Downloaded and edited by fabien.maussion@uibk.ac.at
  • " ], "text/plain": [ "\n", diff --git a/doc/source/geopandas.ipynb b/doc/source/geopandas.ipynb index d986b54..9146b21 100644 --- a/doc/source/geopandas.ipynb +++ b/doc/source/geopandas.ipynb @@ -459,7 +459,7 @@ " * destination (destination) object POLYGON ((-87.60914087617012 41.8446925...\n", "Indexes:\n", " origin GeometryIndex (crs=GEOGCS["WGS84(DD)",DATUM["WGS_1984",SPHEROID["WGS84",6378137,29 ...)\n", - " destination GeometryIndex (crs=GEOGCS["WGS84(DD)",DATUM["WGS_1984",SPHEROID["WGS84",6378137,29 ...)
  • " ], "text/plain": [ "\n", " 2\n", " POLYGON ((-87.60914 41.84469, -87.60915 41.844...\n", - " POLYGON ((-87.62880 41.80189, -87.62879 41.801...\n", + " POLYGON ((-87.6288 41.80189, -87.62879 41.8017...\n", " bike\n", " 2023-02-28\n", " 12\n", @@ -887,7 +907,7 @@ " \n", " 3\n", " POLYGON ((-87.60914 41.84469, -87.60915 41.844...\n", - " POLYGON ((-87.60671 41.81681, -87.60670 41.816...\n", + " POLYGON ((-87.60671 41.81681, -87.6067 41.8165...\n", " bike\n", " 2023-02-28\n", " 12\n", @@ -932,7 +952,7 @@ " \n", " 5926\n", " POLYGON ((-87.80676 42.00084, -87.80676 42.000...\n", - " MULTIPOLYGON (((-87.83658 41.98640, -87.83658 ...\n", + " MULTIPOLYGON (((-87.83658 41.9864, -87.83658 4...\n", " bike\n", " 2023-02-28\n", " 12\n", @@ -978,13 +998,13 @@ " destination mode date \\\n", "0 POLYGON ((-87.60914 41.84469, -87.60915 41.844... bike 2023-02-28 \n", "1 POLYGON ((-87.59215 41.81693, -87.59231 41.816... bike 2023-02-28 \n", - "2 POLYGON ((-87.62880 41.80189, -87.62879 41.801... bike 2023-02-28 \n", - "3 POLYGON ((-87.60671 41.81681, -87.60670 41.816... bike 2023-02-28 \n", + "2 POLYGON ((-87.6288 41.80189, -87.62879 41.8017... bike 2023-02-28 \n", + "3 POLYGON ((-87.60671 41.81681, -87.6067 41.8165... bike 2023-02-28 \n", "4 POLYGON ((-87.59215 41.81693, -87.59215 41.816... bike 2023-02-28 \n", "... ... ... ... \n", "5924 POLYGON ((-87.69646 41.70714, -87.69644 41.706... bike 2023-02-28 \n", "5925 POLYGON ((-87.64215 41.68508, -87.64249 41.685... bike 2023-02-28 \n", - "5926 MULTIPOLYGON (((-87.83658 41.98640, -87.83658 ... bike 2023-02-28 \n", + "5926 MULTIPOLYGON (((-87.83658 41.9864, -87.83658 4... bike 2023-02-28 \n", "5927 POLYGON ((-87.65456 41.99817, -87.65456 41.998... bike 2023-02-28 \n", "5928 POLYGON ((-87.80676 42.00084, -87.80676 42.000... bike 2023-02-28 \n", "\n", @@ -1039,7 +1059,7 @@ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", "Cell \u001b[0;32mIn[4], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mtraffic_counts\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msel\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdate\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m2023-02-28\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtime\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m12\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmode\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbike\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mxvec\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mto_geopandas\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m~/Git/xvec/xvec/accessor.py:754\u001b[0m, in \u001b[0;36mXvecAccessor.to_geopandas\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 748\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[1;32m 749\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCannot convert arrays with \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_obj\u001b[38;5;241m.\u001b[39mndim\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m dimensions into pandas \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 750\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mobjects. Requires 2 or fewer dimensions.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 751\u001b[0m )\n\u001b[1;32m 753\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_geom_indexes) \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m1\u001b[39m:\n\u001b[0;32m--> 754\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[1;32m 755\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mMultiple coordinates based on xvec.GeometryIndex are not supported \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 756\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mas GeoPandas.GeoDataFrame cannot be indexed by geometry. Try using \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 757\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m`.xvec.to_geodataframe()` instead.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 758\u001b[0m )\n\u001b[1;32m 760\u001b[0m \u001b[38;5;66;03m# DataArray\u001b[39;00m\n\u001b[1;32m 761\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_obj, xr\u001b[38;5;241m.\u001b[39mDataArray):\n", + "File \u001b[0;32m~/Git/xvec/xvec/accessor.py:748\u001b[0m, in \u001b[0;36mXvecAccessor.to_geopandas\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 742\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[1;32m 743\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCannot convert arrays with \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_obj\u001b[38;5;241m.\u001b[39mndim\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m dimensions into pandas \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 744\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mobjects. Requires 2 or fewer dimensions.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 745\u001b[0m )\n\u001b[1;32m 747\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_geom_indexes) \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m1\u001b[39m:\n\u001b[0;32m--> 748\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[1;32m 749\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mMultiple coordinates based on xvec.GeometryIndex are not supported \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 750\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mas GeoPandas.GeoDataFrame cannot be indexed by geometry. Try using \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 751\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m`.xvec.to_geodataframe()` instead.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 752\u001b[0m )\n\u001b[1;32m 754\u001b[0m \u001b[38;5;66;03m# DataArray\u001b[39;00m\n\u001b[1;32m 755\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_obj, xr\u001b[38;5;241m.\u001b[39mDataArray):\n", "\u001b[0;31mValueError\u001b[0m: Multiple coordinates based on xvec.GeometryIndex are not supported as GeoPandas.GeoDataFrame cannot be indexed by geometry. Try using `.xvec.to_geodataframe()` instead." ] } @@ -1106,14 +1126,14 @@ " \n", " \n", " 2\n", - " POLYGON ((-87.62880 41.80189, -87.62879 41.801...\n", + " POLYGON ((-87.6288 41.80189, -87.62879 41.8017...\n", " 43\n", " 20\n", " 59\n", " \n", " \n", " 3\n", - " POLYGON ((-87.60671 41.81681, -87.60670 41.816...\n", + " POLYGON ((-87.60671 41.81681, -87.6067 41.8165...\n", " 96\n", " 13\n", " 42\n", @@ -1148,7 +1168,7 @@ " \n", " \n", " 74\n", - " MULTIPOLYGON (((-87.83658 41.98640, -87.83658 ...\n", + " MULTIPOLYGON (((-87.83658 41.9864, -87.83658 4...\n", " 49\n", " 82\n", " 14\n", @@ -1176,13 +1196,13 @@ "mode destination car bike foot\n", "0 POLYGON ((-87.60914 41.84469, -87.60915 41.844... 48 19 97\n", "1 POLYGON ((-87.59215 41.81693, -87.59231 41.816... 77 23 25\n", - "2 POLYGON ((-87.62880 41.80189, -87.62879 41.801... 43 20 59\n", - "3 POLYGON ((-87.60671 41.81681, -87.60670 41.816... 96 13 42\n", + "2 POLYGON ((-87.6288 41.80189, -87.62879 41.8017... 43 20 59\n", + "3 POLYGON ((-87.60671 41.81681, -87.6067 41.8165... 96 13 42\n", "4 POLYGON ((-87.59215 41.81693, -87.59215 41.816... 38 13 48\n", ".. ... ... ... ...\n", "72 POLYGON ((-87.69646 41.70714, -87.69644 41.706... 54 13 22\n", "73 POLYGON ((-87.64215 41.68508, -87.64249 41.685... 76 10 82\n", - "74 MULTIPOLYGON (((-87.83658 41.98640, -87.83658 ... 49 82 14\n", + "74 MULTIPOLYGON (((-87.83658 41.9864, -87.83658 4... 49 82 14\n", "75 POLYGON ((-87.65456 41.99817, -87.65456 41.998... 84 28 16\n", "76 POLYGON ((-87.80676 42.00084, -87.80676 42.000... 59 25 12\n", "\n", @@ -1267,7 +1287,7 @@ " \n", " \n", " car\n", - " POLYGON ((-87.62880 41.80189, -87.62879 41.801...\n", + " POLYGON ((-87.6288 41.80189, -87.62879 41.8017...\n", " 2023-02-28\n", " 12\n", " POLYGON ((-87.60914 41.84469, -87.60915 41.844...\n", @@ -1275,7 +1295,7 @@ " \n", " \n", " car\n", - " POLYGON ((-87.60671 41.81681, -87.60670 41.816...\n", + " POLYGON ((-87.60671 41.81681, -87.6067 41.8165...\n", " 2023-02-28\n", " 12\n", " POLYGON ((-87.60914 41.84469, -87.60915 41.844...\n", @@ -1315,7 +1335,7 @@ " \n", " \n", " foot\n", - " MULTIPOLYGON (((-87.83658 41.98640, -87.83658 ...\n", + " MULTIPOLYGON (((-87.83658 41.9864, -87.83658 4...\n", " 2023-02-28\n", " 12\n", " POLYGON ((-87.60914 41.84469, -87.60915 41.844...\n", @@ -1347,13 +1367,13 @@ "mode \n", "car POLYGON ((-87.60914 41.84469, -87.60915 41.844... 2023-02-28 12 \n", "car POLYGON ((-87.59215 41.81693, -87.59231 41.816... 2023-02-28 12 \n", - "car POLYGON ((-87.62880 41.80189, -87.62879 41.801... 2023-02-28 12 \n", - "car POLYGON ((-87.60671 41.81681, -87.60670 41.816... 2023-02-28 12 \n", + "car POLYGON ((-87.6288 41.80189, -87.62879 41.8017... 2023-02-28 12 \n", + "car POLYGON ((-87.60671 41.81681, -87.6067 41.8165... 2023-02-28 12 \n", "car POLYGON ((-87.59215 41.81693, -87.59215 41.816... 2023-02-28 12 \n", "... ... ... ... \n", "foot POLYGON ((-87.69646 41.70714, -87.69644 41.706... 2023-02-28 12 \n", "foot POLYGON ((-87.64215 41.68508, -87.64249 41.685... 2023-02-28 12 \n", - "foot MULTIPOLYGON (((-87.83658 41.98640, -87.83658 ... 2023-02-28 12 \n", + "foot MULTIPOLYGON (((-87.83658 41.9864, -87.83658 4... 2023-02-28 12 \n", "foot POLYGON ((-87.65456 41.99817, -87.65456 41.998... 2023-02-28 12 \n", "foot POLYGON ((-87.80676 42.00084, -87.80676 42.000... 2023-02-28 12 \n", "\n", @@ -1778,38 +1798,48 @@ " divorce (county, year) float64 1.859 2.62 3.747 ... 2.725 4.782 7.415\n", " age (county, year) float64 28.8 30.5 34.5 ... 26.4 28.97 35.33\n", "Indexes:\n", - " county GeometryIndex (crs=EPSG:4326)
    • year
      PandasIndex
      PandasIndex(Index([1960, 1970, 1980, 1990], dtype='int64', name='year'))
    • county
      GeometryIndex (crs=EPSG:4326)
      GeometryIndex(\n",
      +       "    [<POLYGON ((-95.343 48.547, -95.341 48.715, -95.094 48.717, -95.095 48.912, -...>\n",
      +       "     <POLYGON ((-118.851 47.95, -118.847 48.478, -118.869 48.479, -118.87 48.647,...>\n",
      +       "     <POLYGON ((-117.438 48.044, -117.541 48.043, -117.536 47.79, -117.607 47.798...>\n",
      +       "     <POLYGON ((-118.971 47.939, -118.973 47.96, -118.953 47.989, -118.953 48.02,...>\n",
      +       "     ...\n",
      +       "     <POLYGON ((-107.195 34.584, -107.718 34.584, -108.227 34.583, -109.048 34.59...>\n",
      +       "     <POLYGON ((-76.396 37.108, -76.403 37.091, -76.434 37.089, -76.464 37.103, -...>\n",
      +       "     <POLYGON ((-77.532 38.565, -77.721 38.84, -77.707 38.877, -77.678 38.885, -7...>\n",
      +       "     <POLYGON ((-111.372 44.745, -111.368 45.35, -111.349 45.349, -111.349 45.635...>],\n",
      +       "    crs=EPSG:4326)
  • " ], "text/plain": [ "\n", @@ -1899,7 +1929,7 @@ " \n", " \n", " 1960\n", - " POLYGON ((-95.34258 48.54670, -95.34081 48.715...\n", + " POLYGON ((-95.34258 48.5467, -95.34081 48.7151...\n", " 4304\n", " 7.900000\n", " 1.858974\n", @@ -1907,7 +1937,7 @@ " \n", " \n", " 1970\n", - " POLYGON ((-95.34258 48.54670, -95.34081 48.715...\n", + " POLYGON ((-95.34258 48.5467, -95.34081 48.7151...\n", " 3987\n", " 9.000000\n", " 2.619808\n", @@ -1915,7 +1945,7 @@ " \n", " \n", " 1980\n", - " POLYGON ((-95.34258 48.54670, -95.34081 48.715...\n", + " POLYGON ((-95.34258 48.5467, -95.34081 48.7151...\n", " 3764\n", " 5.902579\n", " 3.746594\n", @@ -1923,7 +1953,7 @@ " \n", " \n", " 1990\n", - " POLYGON ((-95.34258 48.54670, -95.34081 48.715...\n", + " POLYGON ((-95.34258 48.5467, -95.34081 48.7151...\n", " 4076\n", " 3.894790\n", " 7.388535\n", @@ -1931,7 +1961,7 @@ " \n", " \n", " 1960\n", - " POLYGON ((-118.85050 47.94969, -118.84732 48.4...\n", + " POLYGON ((-118.8505 47.94969, -118.84732 48.47...\n", " 3889\n", " 8.200000\n", " 2.863278\n", @@ -1993,11 +2023,11 @@ "text/plain": [ " county population \\\n", "year \n", - "1960 POLYGON ((-95.34258 48.54670, -95.34081 48.715... 4304 \n", - "1970 POLYGON ((-95.34258 48.54670, -95.34081 48.715... 3987 \n", - "1980 POLYGON ((-95.34258 48.54670, -95.34081 48.715... 3764 \n", - "1990 POLYGON ((-95.34258 48.54670, -95.34081 48.715... 4076 \n", - "1960 POLYGON ((-118.85050 47.94969, -118.84732 48.4... 3889 \n", + "1960 POLYGON ((-95.34258 48.5467, -95.34081 48.7151... 4304 \n", + "1970 POLYGON ((-95.34258 48.5467, -95.34081 48.7151... 3987 \n", + "1980 POLYGON ((-95.34258 48.5467, -95.34081 48.7151... 3764 \n", + "1990 POLYGON ((-95.34258 48.5467, -95.34081 48.7151... 4076 \n", + "1960 POLYGON ((-118.8505 47.94969, -118.84732 48.47... 3889 \n", "... ... ... \n", "1990 POLYGON ((-77.53178 38.56506, -77.72094 38.840... 250377 \n", "1960 POLYGON ((-111.37152 44.74516, -111.36839 45.3... 39260 \n", @@ -2096,7 +2126,7 @@ " \n", " \n", " 0\n", - " POLYGON ((-95.34258 48.54670, -95.34081 48.715...\n", + " POLYGON ((-95.34258 48.5467, -95.34081 48.7151...\n", " 4304\n", " 3987\n", " 3764\n", @@ -2116,7 +2146,7 @@ " \n", " \n", " 1\n", - " POLYGON ((-118.85050 47.94969, -118.84732 48.4...\n", + " POLYGON ((-118.8505 47.94969, -118.84732 48.47...\n", " 3889\n", " 3655\n", " 5811\n", @@ -2176,7 +2206,7 @@ " \n", " \n", " 4\n", - " POLYGON ((-117.43750 49.00000, -117.03098 49.0...\n", + " POLYGON ((-117.4375 49, -117.03098 49, -117.02...\n", " 6914\n", " 6025\n", " 8580\n", @@ -2216,7 +2246,7 @@ " \n", " \n", " 3080\n", - " POLYGON ((-114.51984 33.02767, -114.55830 33.0...\n", + " POLYGON ((-114.51984 33.02767, -114.5583 33.03...\n", " 46235\n", " 60827\n", " 90554\n", @@ -2236,7 +2266,7 @@ " \n", " \n", " 3081\n", - " POLYGON ((-107.19484 34.58352, -107.71780 34.5...\n", + " POLYGON ((-107.19484 34.58352, -107.7178 34.58...\n", " 39085\n", " 40576\n", " 61115\n", @@ -2256,7 +2286,7 @@ " \n", " \n", " 3082\n", - " POLYGON ((-76.39569 37.10771, -76.40270 37.090...\n", + " POLYGON ((-76.39569 37.10771, -76.4027 37.0905...\n", " 21583\n", " 33203\n", " 44189\n", @@ -2322,15 +2352,15 @@ "text/plain": [ " county population \\\n", "year 1960 1970 \n", - "0 POLYGON ((-95.34258 48.54670, -95.34081 48.715... 4304 3987 \n", - "1 POLYGON ((-118.85050 47.94969, -118.84732 48.4... 3889 3655 \n", + "0 POLYGON ((-95.34258 48.5467, -95.34081 48.7151... 4304 3987 \n", + "1 POLYGON ((-118.8505 47.94969, -118.84732 48.47... 3889 3655 \n", "2 POLYGON ((-117.43777 48.04422, -117.54113 48.0... 17884 17405 \n", "3 POLYGON ((-118.97096 47.93928, -118.97293 47.9... 25520 25867 \n", - "4 POLYGON ((-117.43750 49.00000, -117.03098 49.0... 6914 6025 \n", + "4 POLYGON ((-117.4375 49, -117.03098 49, -117.02... 6914 6025 \n", "... ... ... ... \n", - "3080 POLYGON ((-114.51984 33.02767, -114.55830 33.0... 46235 60827 \n", - "3081 POLYGON ((-107.19484 34.58352, -107.71780 34.5... 39085 40576 \n", - "3082 POLYGON ((-76.39569 37.10771, -76.40270 37.090... 21583 33203 \n", + "3080 POLYGON ((-114.51984 33.02767, -114.5583 33.03... 46235 60827 \n", + "3081 POLYGON ((-107.19484 34.58352, -107.7178 34.58... 39085 40576 \n", + "3082 POLYGON ((-76.39569 37.10771, -76.4027 37.0905... 21583 33203 \n", "3083 POLYGON ((-77.53178 38.56506, -77.72094 38.840... 50164 111102 \n", "3084 POLYGON ((-111.37152 44.74516, -111.36839 45.3... 39260 43766 \n", "\n", @@ -2400,7 +2430,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.0" + "version": "3.12.1" }, "vscode": { "interpreter": { diff --git a/doc/source/indexing.ipynb b/doc/source/indexing.ipynb index a294ddb..32d932c 100644 --- a/doc/source/indexing.ipynb +++ b/doc/source/indexing.ipynb @@ -426,8 +426,8 @@ " fare_amount (payment_type, date, hour, origin, destination) float64 na...\n", "Indexes:\n", " origin GeometryIndex (crs=EPSG:2263)\n", - " destination GeometryIndex (crs=EPSG:2263)
  • " ], "text/plain": [ "\n", @@ -1157,8 +1177,8 @@ " fare_amount (payment_type, date, hour, origin, destination) float64 na...\n", "Indexes:\n", " origin GeometryIndex (crs=EPSG:2263)\n", - " destination GeometryIndex (crs=EPSG:2263)
  • " ], "text/plain": [ "\n", @@ -1787,12 +1820,12 @@ " fare_amount (payment_type, origin, destination) float64 nan nan ... nan\n", "Indexes:\n", " origin GeometryIndex (crs=EPSG:2263)\n", - " destination GeometryIndex (crs=EPSG:2263)
  • " ], "text/plain": [ "\n", @@ -2290,8 +2329,8 @@ " fare_amount (payment_type, date, hour, origin, destination) float64 na...\n", "Indexes:\n", " origin GeometryIndex (crs=EPSG:2263)\n", - " destination GeometryIndex (crs=EPSG:2263)
  • " ], "text/plain": [ "\n", @@ -2940,8 +2999,8 @@ " fare_amount (payment_type, date, hour, origin, destination) float64 na...\n", "Indexes:\n", " origin GeometryIndex (crs=EPSG:2263)\n", - " destination GeometryIndex (crs=EPSG:2263)
  • " ], "text/plain": [ "\n", @@ -3571,8 +3645,8 @@ " fare_amount (payment_type, date, hour, origin, destination) float64 na...\n", "Indexes:\n", " origin GeometryIndex (crs=EPSG:2263)\n", - " destination GeometryIndex (crs=EPSG:2263)
  • " ], "text/plain": [ "\n", @@ -4202,8 +4289,8 @@ " fare_amount (payment_type, date, hour, origin, destination) float64 na...\n", "Indexes:\n", " origin GeometryIndex (crs=EPSG:2263)\n", - " destination GeometryIndex (crs=EPSG:2263)
  • " ], "text/plain": [ "\n", @@ -4833,8 +4930,8 @@ " fare_amount (payment_type, date, hour, origin, destination) float64 na...\n", "Indexes:\n", " origin GeometryIndex (crs=EPSG:2263)\n", - " destination GeometryIndex (crs=EPSG:2263)
  • " ], "text/plain": [ "\n", @@ -5089,7 +5200,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.0" + "version": "3.12.1" }, "vscode": { "interpreter": { diff --git a/doc/source/intro.ipynb b/doc/source/intro.ipynb index 789552d..fd29e2b 100644 --- a/doc/source/intro.ipynb +++ b/doc/source/intro.ipynb @@ -429,14 +429,14 @@ "
    <xarray.DataArray 'PO60' (county: 3085)>\n",
            "array([ 4304,  3889, 17884, ..., 21583, 50164, 39260])\n",
            "Coordinates:\n",
    -       "  * county   (county) object POLYGON ((-95.34258270263672 48.54670333862305, ...
  • " ], "text/plain": [ "\n", @@ -899,20 +899,30 @@ " * county (county) object POLYGON ((-95.34258270263672 48.54670333862305, ...\n", " * year (year) int64 1960 1970 1980 1990\n", "Indexes:\n", - " county GeometryIndex (crs=EPSG:4326)
    • year
      PandasIndex
      PandasIndex(Index([1960, 1970, 1980, 1990], dtype='int64', name='year'))
    • county
      GeometryIndex (crs=EPSG:4326)
      GeometryIndex(\n",
      +       "    [<POLYGON ((-95.343 48.547, -95.341 48.715, -95.094 48.717, -95.095 48.912, -...>\n",
      +       "     <POLYGON ((-118.851 47.95, -118.847 48.478, -118.869 48.479, -118.87 48.647,...>\n",
      +       "     <POLYGON ((-117.438 48.044, -117.541 48.043, -117.536 47.79, -117.607 47.798...>\n",
      +       "     <POLYGON ((-118.971 47.939, -118.973 47.96, -118.953 47.989, -118.953 48.02,...>\n",
      +       "     ...\n",
      +       "     <POLYGON ((-107.195 34.584, -107.718 34.584, -108.227 34.583, -109.048 34.59...>\n",
      +       "     <POLYGON ((-76.396 37.108, -76.403 37.091, -76.434 37.089, -76.464 37.103, -...>\n",
      +       "     <POLYGON ((-77.532 38.565, -77.721 38.84, -77.707 38.877, -77.678 38.885, -7...>\n",
      +       "     <POLYGON ((-111.372 44.745, -111.368 45.35, -111.349 45.349, -111.349 45.635...>],\n",
      +       "    crs=EPSG:4326)
  • " ], "text/plain": [ "\n", @@ -1339,38 +1349,48 @@ " divorce (county, year) float64 1.859 2.62 3.747 ... 2.725 4.782 7.415\n", " age (county, year) float64 28.8 30.5 34.5 ... 26.4 28.97 35.33\n", "Indexes:\n", - " county GeometryIndex (crs=EPSG:4326)
    • year
      PandasIndex
      PandasIndex(Index([1960, 1970, 1980, 1990], dtype='int64', name='year'))
    • county
      GeometryIndex (crs=EPSG:4326)
      GeometryIndex(\n",
      +       "    [<POLYGON ((-95.343 48.547, -95.341 48.715, -95.094 48.717, -95.095 48.912, -...>\n",
      +       "     <POLYGON ((-118.851 47.95, -118.847 48.478, -118.869 48.479, -118.87 48.647,...>\n",
      +       "     <POLYGON ((-117.438 48.044, -117.541 48.043, -117.536 47.79, -117.607 47.798...>\n",
      +       "     <POLYGON ((-118.971 47.939, -118.973 47.96, -118.953 47.989, -118.953 48.02,...>\n",
      +       "     ...\n",
      +       "     <POLYGON ((-107.195 34.584, -107.718 34.584, -108.227 34.583, -109.048 34.59...>\n",
      +       "     <POLYGON ((-76.396 37.108, -76.403 37.091, -76.434 37.089, -76.464 37.103, -...>\n",
      +       "     <POLYGON ((-77.532 38.565, -77.721 38.84, -77.707 38.877, -77.678 38.885, -7...>\n",
      +       "     <POLYGON ((-111.372 44.745, -111.368 45.35, -111.349 45.349, -111.349 45.635...>],\n",
      +       "    crs=EPSG:4326)
  • " ], "text/plain": [ "\n", diff --git a/doc/source/io.ipynb b/doc/source/io.ipynb index 29a3a72..7d0fc41 100644 --- a/doc/source/io.ipynb +++ b/doc/source/io.ipynb @@ -424,38 +424,48 @@ " divorce (county, year) float64 1.859 2.62 3.747 ... 2.725 4.782 7.415\n", " age (county, year) float64 28.8 30.5 34.5 ... 26.4 28.97 35.33\n", "Indexes:\n", - " county GeometryIndex (crs=EPSG:4326)
    • year
      PandasIndex
      PandasIndex(Index([1960, 1970, 1980, 1990], dtype='int64', name='year'))
    • county
      GeometryIndex (crs=EPSG:4326)
      GeometryIndex(\n",
      +       "    [<POLYGON ((-95.343 48.547, -95.341 48.715, -95.094 48.717, -95.095 48.912, -...>\n",
      +       "     <POLYGON ((-118.851 47.95, -118.847 48.478, -118.869 48.479, -118.87 48.647,...>\n",
      +       "     <POLYGON ((-117.438 48.044, -117.541 48.043, -117.536 47.79, -117.607 47.798...>\n",
      +       "     <POLYGON ((-118.971 47.939, -118.973 47.96, -118.953 47.989, -118.953 48.02,...>\n",
      +       "     ...\n",
      +       "     <POLYGON ((-107.195 34.584, -107.718 34.584, -108.227 34.583, -109.048 34.59...>\n",
      +       "     <POLYGON ((-76.396 37.108, -76.403 37.091, -76.434 37.089, -76.464 37.103, -...>\n",
      +       "     <POLYGON ((-77.532 38.565, -77.721 38.84, -77.707 38.877, -77.678 38.885, -7...>\n",
      +       "     <POLYGON ((-111.372 44.745, -111.368 45.35, -111.349 45.349, -111.349 45.635...>],\n",
      +       "    crs=EPSG:4326)
  • " ], "text/plain": [ "\n", @@ -904,38 +914,48 @@ " divorce (county, year) float64 1.859 2.62 3.747 ... 2.725 4.782 7.415\n", " age (county, year) float64 28.8 30.5 34.5 ... 26.4 28.97 35.33\n", "Indexes:\n", - " county GeometryIndex (crs=EPSG:4326)
    • year
      PandasIndex
      PandasIndex(Index([1960, 1970, 1980, 1990], dtype='int64', name='year'))
    • county
      GeometryIndex (crs=EPSG:4326)
      GeometryIndex(\n",
      +       "    [<POLYGON ((-95.343 48.547, -95.341 48.715, -95.094 48.717, -95.095 48.912, -...>\n",
      +       "     <POLYGON ((-118.851 47.95, -118.847 48.478, -118.869 48.479, -118.87 48.647,...>\n",
      +       "     <POLYGON ((-117.438 48.044, -117.541 48.043, -117.536 47.79, -117.607 47.798...>\n",
      +       "     <POLYGON ((-118.971 47.939, -118.973 47.96, -118.953 47.989, -118.953 48.02,...>\n",
      +       "     ...\n",
      +       "     <POLYGON ((-107.195 34.584, -107.718 34.584, -108.227 34.583, -109.048 34.59...>\n",
      +       "     <POLYGON ((-76.396 37.108, -76.403 37.091, -76.434 37.089, -76.464 37.103, -...>\n",
      +       "     <POLYGON ((-77.532 38.565, -77.721 38.84, -77.707 38.877, -77.678 38.885, -7...>\n",
      +       "     <POLYGON ((-111.372 44.745, -111.368 45.35, -111.349 45.349, -111.349 45.635...>],\n",
      +       "    crs=EPSG:4326)
  • " ], "text/plain": [ "\n", @@ -1376,38 +1396,48 @@ " divorce (county, year) float64 1.859 2.62 3.747 ... 2.725 4.782 7.415\n", " age (county, year) float64 28.8 30.5 34.5 ... 26.4 28.97 35.33\n", "Indexes:\n", - " county GeometryIndex (crs=EPSG:4326)
    • year
      PandasIndex
      PandasIndex(Index([1960, 1970, 1980, 1990], dtype='int64', name='year'))
    • county
      GeometryIndex (crs=EPSG:4326)
      GeometryIndex(\n",
      +       "    [<POLYGON ((-95.343 48.547, -95.341 48.715, -95.094 48.717, -95.095 48.912, -...>\n",
      +       "     <POLYGON ((-118.851 47.95, -118.847 48.478, -118.869 48.479, -118.87 48.647,...>\n",
      +       "     <POLYGON ((-117.438 48.044, -117.541 48.043, -117.536 47.79, -117.607 47.798...>\n",
      +       "     <POLYGON ((-118.971 47.939, -118.973 47.96, -118.953 47.989, -118.953 48.02,...>\n",
      +       "     ...\n",
      +       "     <POLYGON ((-107.195 34.584, -107.718 34.584, -108.227 34.583, -109.048 34.59...>\n",
      +       "     <POLYGON ((-76.396 37.108, -76.403 37.091, -76.434 37.089, -76.464 37.103, -...>\n",
      +       "     <POLYGON ((-77.532 38.565, -77.721 38.84, -77.707 38.877, -77.678 38.885, -7...>\n",
      +       "     <POLYGON ((-111.372 44.745, -111.368 45.35, -111.349 45.349, -111.349 45.635...>],\n",
      +       "    crs=EPSG:4326)
  • " ], "text/plain": [ "\n", @@ -1497,7 +1527,7 @@ " \n", " \n", " 1960\n", - " POLYGON ((-95.34258 48.54670, -95.34081 48.715...\n", + " POLYGON ((-95.34258 48.5467, -95.34081 48.7151...\n", " 4304\n", " 7.900000\n", " 1.858974\n", @@ -1505,7 +1535,7 @@ " \n", " \n", " 1970\n", - " POLYGON ((-95.34258 48.54670, -95.34081 48.715...\n", + " POLYGON ((-95.34258 48.5467, -95.34081 48.7151...\n", " 3987\n", " 9.000000\n", " 2.619808\n", @@ -1513,7 +1543,7 @@ " \n", " \n", " 1980\n", - " POLYGON ((-95.34258 48.54670, -95.34081 48.715...\n", + " POLYGON ((-95.34258 48.5467, -95.34081 48.7151...\n", " 3764\n", " 5.902579\n", " 3.746594\n", @@ -1521,7 +1551,7 @@ " \n", " \n", " 1990\n", - " POLYGON ((-95.34258 48.54670, -95.34081 48.715...\n", + " POLYGON ((-95.34258 48.5467, -95.34081 48.7151...\n", " 4076\n", " 3.894790\n", " 7.388535\n", @@ -1529,7 +1559,7 @@ " \n", " \n", " 1960\n", - " POLYGON ((-118.85050 47.94969, -118.84732 48.4...\n", + " POLYGON ((-118.8505 47.94969, -118.84732 48.47...\n", " 3889\n", " 8.200000\n", " 2.863278\n", @@ -1591,11 +1621,11 @@ "text/plain": [ " county population \\\n", "year \n", - "1960 POLYGON ((-95.34258 48.54670, -95.34081 48.715... 4304 \n", - "1970 POLYGON ((-95.34258 48.54670, -95.34081 48.715... 3987 \n", - "1980 POLYGON ((-95.34258 48.54670, -95.34081 48.715... 3764 \n", - "1990 POLYGON ((-95.34258 48.54670, -95.34081 48.715... 4076 \n", - "1960 POLYGON ((-118.85050 47.94969, -118.84732 48.4... 3889 \n", + "1960 POLYGON ((-95.34258 48.5467, -95.34081 48.7151... 4304 \n", + "1970 POLYGON ((-95.34258 48.5467, -95.34081 48.7151... 3987 \n", + "1980 POLYGON ((-95.34258 48.5467, -95.34081 48.7151... 3764 \n", + "1990 POLYGON ((-95.34258 48.5467, -95.34081 48.7151... 4076 \n", + "1960 POLYGON ((-118.8505 47.94969, -118.84732 48.47... 3889 \n", "... ... ... \n", "1990 POLYGON ((-77.53178 38.56506, -77.72094 38.840... 250377 \n", "1960 POLYGON ((-111.37152 44.74516, -111.36839 45.3... 39260 \n", @@ -2045,34 +2075,44 @@ " divorce (year, county) float64 1.584 1.219 1.148 ... 9.628 7.917 8.998\n", " age (year, county) float64 20.5 18.9 19.8 20.2 ... 37.0 27.2 34.1\n", "Indexes:\n", - " county GeometryIndex (crs=EPSG:4326)
    • year
      PandasIndex
      PandasIndex(Index([1960, 1970, 1980, 1990], dtype='int64', name='year'))
    • county
      GeometryIndex (crs=EPSG:4326)
      GeometryIndex(\n",
      +       "    [<MULTIPOLYGON (((-97.251 26.419, -97.232 26.418, -97.195 26.259, -97.172 26....>\n",
      +       "     <MULTIPOLYGON (((-97.869 26.348, -97.874 26.447, -98.005 26.464, -97.989 26....>\n",
      +       "     <POLYGON ((-98.6 26.26, -98.341 26.787, -97.991 26.786, -97.992 26.617, -97....>\n",
      +       "     <POLYGON ((-98.6 26.26, -98.678 26.242, -98.82 26.375, -98.909 26.36, -98.93...>\n",
      +       "     ...\n",
      +       "     <POLYGON ((-81.11 29.43, -81.151 29.418, -81.146 29.264, -81.413 29.263, -81...>\n",
      +       "     <POLYGON ((-81.52 29.626, -81.521 29.755, -81.563 29.806, -81.582 29.842, -8...>\n",
      +       "     <MULTIPOLYGON (((-81.529 30.721, -81.537 30.706, -81.601 30.725, -81.605 30....>\n",
      +       "     <POLYGON ((-81.536 31.077, -81.561 31.085, -81.564 31.121, -81.639 31.112, -...>],\n",
      +       "    crs=EPSG:4326)
  • " ], "text/plain": [ "\n", @@ -2169,7 +2209,7 @@ " \n", " \n", " 0\n", - " POLYGON ((-95.34258 48.54670, -95.34081 48.715...\n", + " POLYGON ((-95.34258 48.5467, -95.34081 48.7151...\n", " 4304\n", " 3987\n", " 3764\n", @@ -2189,7 +2229,7 @@ " \n", " \n", " 1\n", - " POLYGON ((-118.85050 47.94969, -118.84732 48.4...\n", + " POLYGON ((-118.8505 47.94969, -118.84732 48.47...\n", " 3889\n", " 3655\n", " 5811\n", @@ -2249,7 +2289,7 @@ " \n", " \n", " 4\n", - " POLYGON ((-117.43750 49.00000, -117.03098 49.0...\n", + " POLYGON ((-117.4375 49, -117.03098 49, -117.02...\n", " 6914\n", " 6025\n", " 8580\n", @@ -2289,7 +2329,7 @@ " \n", " \n", " 3080\n", - " POLYGON ((-114.51984 33.02767, -114.55830 33.0...\n", + " POLYGON ((-114.51984 33.02767, -114.5583 33.03...\n", " 46235\n", " 60827\n", " 90554\n", @@ -2309,7 +2349,7 @@ " \n", " \n", " 3081\n", - " POLYGON ((-107.19484 34.58352, -107.71780 34.5...\n", + " POLYGON ((-107.19484 34.58352, -107.7178 34.58...\n", " 39085\n", " 40576\n", " 61115\n", @@ -2329,7 +2369,7 @@ " \n", " \n", " 3082\n", - " POLYGON ((-76.39569 37.10771, -76.40270 37.090...\n", + " POLYGON ((-76.39569 37.10771, -76.4027 37.0905...\n", " 21583\n", " 33203\n", " 44189\n", @@ -2395,15 +2435,15 @@ "text/plain": [ " county population \\\n", "year 1960 1970 \n", - "0 POLYGON ((-95.34258 48.54670, -95.34081 48.715... 4304 3987 \n", - "1 POLYGON ((-118.85050 47.94969, -118.84732 48.4... 3889 3655 \n", + "0 POLYGON ((-95.34258 48.5467, -95.34081 48.7151... 4304 3987 \n", + "1 POLYGON ((-118.8505 47.94969, -118.84732 48.47... 3889 3655 \n", "2 POLYGON ((-117.43777 48.04422, -117.54113 48.0... 17884 17405 \n", "3 POLYGON ((-118.97096 47.93928, -118.97293 47.9... 25520 25867 \n", - "4 POLYGON ((-117.43750 49.00000, -117.03098 49.0... 6914 6025 \n", + "4 POLYGON ((-117.4375 49, -117.03098 49, -117.02... 6914 6025 \n", "... ... ... ... \n", - "3080 POLYGON ((-114.51984 33.02767, -114.55830 33.0... 46235 60827 \n", - "3081 POLYGON ((-107.19484 34.58352, -107.71780 34.5... 39085 40576 \n", - "3082 POLYGON ((-76.39569 37.10771, -76.40270 37.090... 21583 33203 \n", + "3080 POLYGON ((-114.51984 33.02767, -114.5583 33.03... 46235 60827 \n", + "3081 POLYGON ((-107.19484 34.58352, -107.7178 34.58... 39085 40576 \n", + "3082 POLYGON ((-76.39569 37.10771, -76.4027 37.0905... 21583 33203 \n", "3083 POLYGON ((-77.53178 38.56506, -77.72094 38.840... 50164 111102 \n", "3084 POLYGON ((-111.37152 44.74516, -111.36839 45.3... 39260 43766 \n", "\n", @@ -2462,6 +2502,14 @@ "tags": [] }, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/var/folders/2f/fhks6w_d0k556plcv3rfmshw0000gn/T/ipykernel_6430/2455462364.py:1: FutureWarning: The previous implementation of stack is deprecated and will be removed in a future version of pandas. See the What's New notes for pandas 2.1.0 for details. Specify future_stack=True to adopt the new implementation and silence this warning.\n", + " wide.set_index(\"county\", append=True).stack().reset_index(\n" + ] + }, { "data": { "text/html": [ @@ -2839,38 +2887,48 @@ " divorce (county, year) float64 1.584 1.91 3.21 ... 2.502 6.656 8.998\n", " age (county, year) float64 20.5 21.8 25.0 27.4 ... 25.3 30.1 34.1\n", "Indexes:\n", - " county GeometryIndex (crs=EPSG:4326)
    • year
      PandasIndex
      PandasIndex(Index([1960, 1970, 1980, 1990], dtype='object', name='year'))
    • county
      GeometryIndex (crs=EPSG:4326)
      GeometryIndex(\n",
      +       "    [<MULTIPOLYGON (((-97.251 26.419, -97.232 26.418, -97.195 26.259, -97.172 26....>\n",
      +       "     <MULTIPOLYGON (((-97.869 26.348, -97.874 26.447, -98.005 26.464, -97.989 26....>\n",
      +       "     <POLYGON ((-98.6 26.26, -98.341 26.787, -97.991 26.786, -97.992 26.617, -97....>\n",
      +       "     <POLYGON ((-98.6 26.26, -98.678 26.242, -98.82 26.375, -98.909 26.36, -98.93...>\n",
      +       "     ...\n",
      +       "     <POLYGON ((-81.11 29.43, -81.151 29.418, -81.146 29.264, -81.413 29.263, -81...>\n",
      +       "     <POLYGON ((-81.52 29.626, -81.521 29.755, -81.563 29.806, -81.582 29.842, -8...>\n",
      +       "     <MULTIPOLYGON (((-81.529 30.721, -81.537 30.706, -81.601 30.725, -81.605 30....>\n",
      +       "     <POLYGON ((-81.536 31.077, -81.561 31.085, -81.564 31.121, -81.639 31.112, -...>],\n",
      +       "    crs=EPSG:4326)
  • " ], "text/plain": [ "\n", @@ -2915,7 +2973,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.0" + "version": "3.12.1" }, "vscode": { "interpreter": { diff --git a/doc/source/projections.ipynb b/doc/source/projections.ipynb index 7cdb970..7fd1948 100644 --- a/doc/source/projections.ipynb +++ b/doc/source/projections.ipynb @@ -420,9 +420,9 @@ " tip_amount (payment_type, date, hour, origin, destination) float64 na...\n", " fare_amount (payment_type, date, hour, origin, destination) float64 na...\n", "Indexes:\n", - " origin GeometryIndex (crs=EPSG:2263)\n", - " destination GeometryIndex (crs=EPSG:2263)
  • " ], "text/plain": [ "\n", @@ -645,8 +665,8 @@ " tip_amount (payment_type, date, hour, origin, destination) float64 na...\n", " fare_amount (payment_type, date, hour, origin, destination) float64 na...\n", "Indexes:\n", - " origin GeometryIndex (crs=EPSG:2263)\n", - " destination GeometryIndex (crs=EPSG:2263)" + " origin GeometryIndex (crs=EPSG:2263)\n", + " destination GeometryIndex (crs=EPSG:2263)" ] }, "execution_count": 2, @@ -1244,9 +1264,9 @@ " tip_amount (payment_type, date, hour, origin, destination) float64 na...\n", " fare_amount (payment_type, date, hour, origin, destination) float64 na...\n", "Indexes:\n", - " origin GeometryIndex (crs=EPSG:4326)\n", - " destination GeometryIndex (crs=EPSG:3857)
  • " ], "text/plain": [ "\n", @@ -1469,8 +1509,8 @@ " tip_amount (payment_type, date, hour, origin, destination) float64 na...\n", " fare_amount (payment_type, date, hour, origin, destination) float64 na...\n", "Indexes:\n", - " origin GeometryIndex (crs=EPSG:4326)\n", - " destination GeometryIndex (crs=EPSG:3857)" + " origin GeometryIndex (crs=EPSG:4326)\n", + " destination GeometryIndex (crs=EPSG:3857)" ] }, "execution_count": 6, @@ -1878,9 +1918,9 @@ " tip_amount (payment_type, date, hour, origin, destination) float64 na...\n", " fare_amount (payment_type, date, hour, origin, destination) float64 na...\n", "Indexes:\n", - " origin GeometryIndex (crs=EPSG:4326)\n", - " destination GeometryIndex (crs=EPSG:3857)
  • " ], "text/plain": [ "\n", @@ -2103,8 +2163,8 @@ " tip_amount (payment_type, date, hour, origin, destination) float64 na...\n", " fare_amount (payment_type, date, hour, origin, destination) float64 na...\n", "Indexes:\n", - " origin GeometryIndex (crs=EPSG:4326)\n", - " destination GeometryIndex (crs=EPSG:3857)" + " origin GeometryIndex (crs=EPSG:4326)\n", + " destination GeometryIndex (crs=EPSG:3857)" ] }, "execution_count": 7, @@ -2156,7 +2216,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.0" + "version": "3.12.1" }, "orig_nbformat": 4, "vscode": { diff --git a/doc/source/zonal_stats.ipynb b/doc/source/zonal_stats.ipynb index 6a2d9f2..9a0ac80 100644 --- a/doc/source/zonal_stats.ipynb +++ b/doc/source/zonal_stats.ipynb @@ -33,7 +33,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -415,18 +415,18 @@ " v (month, level, latitude, longitude) float64 ...\n", "Attributes:\n", " Conventions: CF-1.0\n", - " Info: Monthly ERA-Interim data. Downloaded and edited by fabien.m...
  • Conventions :
    CF-1.0
    Info :
    Monthly ERA-Interim data. Downloaded and edited by fabien.maussion@uibk.ac.at
  • " ], "text/plain": [ "\n", @@ -445,7 +445,7 @@ " Info: Monthly ERA-Interim data. Downloaded and edited by fabien.m..." ] }, - "execution_count": 7, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } @@ -468,7 +468,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -511,7 +511,7 @@ " Land\n", " 1\n", " 1.0\n", - " POLYGON ((-159.20818 -79.49706, -161.12760 -79...\n", + " POLYGON ((-159.20818 -79.49706, -161.1276 -79....\n", " \n", " \n", " 2\n", @@ -534,84 +534,27 @@ " 1.0\n", " POLYGON ((-125.55957 -73.48135, -124.03188 -73...\n", " \n", - " \n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " ...\n", - " \n", - " \n", - " 122\n", - " Land\n", - " 1\n", - " 1.0\n", - " POLYGON ((51.13619 80.54728, 49.79368 80.41543...\n", - " \n", - " \n", - " 123\n", - " Land\n", - " 0\n", - " 0.0\n", - " POLYGON ((99.93976 78.88094, 97.75794 78.75620...\n", - " \n", - " \n", - " 124\n", - " Land\n", - " 0\n", - " 0.0\n", - " POLYGON ((-87.02000 79.66000, -85.81435 79.336...\n", - " \n", - " \n", - " 125\n", - " Land\n", - " 0\n", - " 0.0\n", - " POLYGON ((-68.50000 83.10632, -65.82735 83.028...\n", - " \n", - " \n", - " 126\n", - " Land\n", - " 0\n", - " 0.0\n", - " POLYGON ((-27.10046 83.51966, -20.84539 82.726...\n", - " \n", " \n", "\n", - "

    127 rows × 4 columns

    \n", "" ], "text/plain": [ - " featurecla scalerank min_zoom \\\n", - "0 Land 1 1.0 \n", - "1 Land 1 1.0 \n", - "2 Land 1 0.0 \n", - "3 Land 1 1.0 \n", - "4 Land 1 1.0 \n", - ".. ... ... ... \n", - "122 Land 1 1.0 \n", - "123 Land 0 0.0 \n", - "124 Land 0 0.0 \n", - "125 Land 0 0.0 \n", - "126 Land 0 0.0 \n", - "\n", - " geometry \n", - "0 POLYGON ((-59.57209 -80.04018, -59.86585 -80.5... \n", - "1 POLYGON ((-159.20818 -79.49706, -161.12760 -79... \n", - "2 POLYGON ((-45.15476 -78.04707, -43.92083 -78.4... \n", - "3 POLYGON ((-121.21151 -73.50099, -119.91885 -73... \n", - "4 POLYGON ((-125.55957 -73.48135, -124.03188 -73... \n", - ".. ... \n", - "122 POLYGON ((51.13619 80.54728, 49.79368 80.41543... \n", - "123 POLYGON ((99.93976 78.88094, 97.75794 78.75620... \n", - "124 POLYGON ((-87.02000 79.66000, -85.81435 79.336... \n", - "125 POLYGON ((-68.50000 83.10632, -65.82735 83.028... \n", - "126 POLYGON ((-27.10046 83.51966, -20.84539 82.726... \n", - "\n", - "[127 rows x 4 columns]" + " featurecla scalerank min_zoom \\\n", + "0 Land 1 1.0 \n", + "1 Land 1 1.0 \n", + "2 Land 1 0.0 \n", + "3 Land 1 1.0 \n", + "4 Land 1 1.0 \n", + "\n", + " geometry \n", + "0 POLYGON ((-59.57209 -80.04018, -59.86585 -80.5... \n", + "1 POLYGON ((-159.20818 -79.49706, -161.1276 -79.... \n", + "2 POLYGON ((-45.15476 -78.04707, -43.92083 -78.4... \n", + "3 POLYGON ((-121.21151 -73.50099, -119.91885 -73... \n", + "4 POLYGON ((-125.55957 -73.48135, -124.03188 -73... " ] }, - "execution_count": 5, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -632,7 +575,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -1015,7 +958,7 @@ " geometry GeometryIndex (crs=EPSG:4326)\n", "Attributes:\n", " Conventions: CF-1.0\n", - " Info: Monthly ERA-Interim data. Downloaded and edited by fabien.m...
    • level
      PandasIndex
      PandasIndex(Index([200, 500, 850], dtype='int32', name='level'))
    • month
      PandasIndex
      PandasIndex(Index([1, 7], dtype='int32', name='month'))
    • geometry
      GeometryIndex (crs=EPSG:4326)
      GeometryIndex(\n",
      +       "    [<POLYGON ((-59.572 -80.04, -59.866 -80.55, -60.16 -81, -62.255 -80.863, -64....>\n",
      +       "     <POLYGON ((-159.208 -79.497, -161.128 -79.634, -162.44 -79.281, -163.027 -78...>\n",
      +       "     <POLYGON ((-45.155 -78.047, -43.921 -78.478, -43.49 -79.086, -43.372 -79.517...>\n",
      +       "     <POLYGON ((-121.212 -73.501, -119.919 -73.658, -118.724 -73.481, -119.292 -7...>\n",
      +       "     ...\n",
      +       "     <POLYGON ((99.94 78.881, 97.758 78.756, 94.973 79.045, 93.313 79.427, 92.545...>\n",
      +       "     <POLYGON ((-87.02 79.66, -85.814 79.337, -87.188 79.039, -89.035 78.287, -90...>\n",
      +       "     <POLYGON ((-68.5 83.106, -65.827 83.028, -63.68 82.9, -61.85 82.629, -61.894...>\n",
      +       "     <POLYGON ((-27.1 83.52, -20.845 82.727, -22.692 82.342, -26.518 82.298, -31....>],\n",
      +       "    crs=EPSG:4326)
  • Conventions :
    CF-1.0
    Info :
    Monthly ERA-Interim data. Downloaded and edited by fabien.maussion@uibk.ac.at
  • " ], "text/plain": [ "\n", @@ -1282,7 +1235,7 @@ " Info: Monthly ERA-Interim data. Downloaded and edited by fabien.m..." ] }, - "execution_count": 5, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -1305,7 +1258,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -1688,7 +1641,7 @@ " geometry GeometryIndex (crs=EPSG:4326)\n", "Attributes:\n", " Conventions: CF-1.0\n", - " Info: Monthly ERA-Interim data. Downloaded and edited by fabien.m...
    • level
      PandasIndex
      PandasIndex(Index([200, 500, 850], dtype='int32', name='level'))
    • month
      PandasIndex
      PandasIndex(Index([1, 7], dtype='int32', name='month'))
    • geometry
      GeometryIndex (crs=EPSG:4326)
      GeometryIndex(\n",
      +       "    [<POLYGON ((-59.572 -80.04, -59.866 -80.55, -60.16 -81, -62.255 -80.863, -64....>\n",
      +       "     <POLYGON ((-159.208 -79.497, -161.128 -79.634, -162.44 -79.281, -163.027 -78...>\n",
      +       "     <POLYGON ((-45.155 -78.047, -43.921 -78.478, -43.49 -79.086, -43.372 -79.517...>\n",
      +       "     <POLYGON ((-121.212 -73.501, -119.919 -73.658, -118.724 -73.481, -119.292 -7...>\n",
      +       "     ...\n",
      +       "     <POLYGON ((99.94 78.881, 97.758 78.756, 94.973 79.045, 93.313 79.427, 92.545...>\n",
      +       "     <POLYGON ((-87.02 79.66, -85.814 79.337, -87.188 79.039, -89.035 78.287, -90...>\n",
      +       "     <POLYGON ((-68.5 83.106, -65.827 83.028, -63.68 82.9, -61.85 82.629, -61.894...>\n",
      +       "     <POLYGON ((-27.1 83.52, -20.845 82.727, -22.692 82.342, -26.518 82.298, -31....>],\n",
      +       "    crs=EPSG:4326)
  • Conventions :
    CF-1.0
    Info :
    Monthly ERA-Interim data. Downloaded and edited by fabien.maussion@uibk.ac.at
  • " ], "text/plain": [ "\n", @@ -1955,7 +1918,7 @@ " Info: Monthly ERA-Interim data. Downloaded and edited by fabien.m..." ] }, - "execution_count": 6, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -1976,7 +1939,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -2360,7 +2323,7 @@ " geometry GeometryIndex (crs=EPSG:4326)\n", "Attributes:\n", " Conventions: CF-1.0\n", - " Info: Monthly ERA-Interim data. Downloaded and edited by fabien.m...
    • level
      PandasIndex
      PandasIndex(Index([200, 500, 850], dtype='int32', name='level'))
    • month
      PandasIndex
      PandasIndex(Index([1, 7], dtype='int32', name='month'))
    • zonal_statistics
      PandasIndex
      PandasIndex(Index(['mean', 'sum'], dtype='object', name='zonal_statistics'))
    • geometry
      GeometryIndex (crs=EPSG:4326)
      GeometryIndex(\n",
      +       "    [<POLYGON ((-59.572 -80.04, -59.866 -80.55, -60.16 -81, -62.255 -80.863, -64....>\n",
      +       "     <POLYGON ((-159.208 -79.497, -161.128 -79.634, -162.44 -79.281, -163.027 -78...>\n",
      +       "     <POLYGON ((-45.155 -78.047, -43.921 -78.478, -43.49 -79.086, -43.372 -79.517...>\n",
      +       "     <POLYGON ((-121.212 -73.501, -119.919 -73.658, -118.724 -73.481, -119.292 -7...>\n",
      +       "     ...\n",
      +       "     <POLYGON ((99.94 78.881, 97.758 78.756, 94.973 79.045, 93.313 79.427, 92.545...>\n",
      +       "     <POLYGON ((-87.02 79.66, -85.814 79.337, -87.188 79.039, -89.035 78.287, -90...>\n",
      +       "     <POLYGON ((-68.5 83.106, -65.827 83.028, -63.68 82.9, -61.85 82.629, -61.894...>\n",
      +       "     <POLYGON ((-27.1 83.52, -20.845 82.727, -22.692 82.342, -26.518 82.298, -31....>],\n",
      +       "    crs=EPSG:4326)
  • Conventions :
    CF-1.0
    Info :
    Monthly ERA-Interim data. Downloaded and edited by fabien.maussion@uibk.ac.at
  • " ], "text/plain": [ "\n", @@ -2628,7 +2601,7 @@ " Info: Monthly ERA-Interim data. Downloaded and edited by fabien.m..." ] }, - "execution_count": 7, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -2649,7 +2622,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -3035,7 +3008,7 @@ " geometry GeometryIndex (crs=EPSG:4326)\n", "Attributes:\n", " Conventions: CF-1.0\n", - " Info: Monthly ERA-Interim data. Downloaded and edited by fabien.m...
    • level
      PandasIndex
      PandasIndex(Index([200, 500, 850], dtype='int32', name='level'))
    • month
      PandasIndex
      PandasIndex(Index([1, 7], dtype='int32', name='month'))
    • quantile
      PandasIndex
      PandasIndex(Index([0.1, 0.2, 0.3], dtype='float64', name='quantile'))
    • zonal_statistics
      PandasIndex
      PandasIndex(Index(['mean', 'sum', 'quantile', 'numpymean', 'nanstd'], dtype='object', name='zonal_statistics'))
    • geometry
      GeometryIndex (crs=EPSG:4326)
      GeometryIndex(\n",
      +       "    [<POLYGON ((-59.572 -80.04, -59.866 -80.55, -60.16 -81, -62.255 -80.863, -64....>\n",
      +       "     <POLYGON ((-159.208 -79.497, -161.128 -79.634, -162.44 -79.281, -163.027 -78...>\n",
      +       "     <POLYGON ((-45.155 -78.047, -43.921 -78.478, -43.49 -79.086, -43.372 -79.517...>\n",
      +       "     <POLYGON ((-121.212 -73.501, -119.919 -73.658, -118.724 -73.481, -119.292 -7...>\n",
      +       "     ...\n",
      +       "     <POLYGON ((99.94 78.881, 97.758 78.756, 94.973 79.045, 93.313 79.427, 92.545...>\n",
      +       "     <POLYGON ((-87.02 79.66, -85.814 79.337, -87.188 79.039, -89.035 78.287, -90...>\n",
      +       "     <POLYGON ((-68.5 83.106, -65.827 83.028, -63.68 82.9, -61.85 82.629, -61.894...>\n",
      +       "     <POLYGON ((-27.1 83.52, -20.845 82.727, -22.692 82.342, -26.518 82.298, -31....>],\n",
      +       "    crs=EPSG:4326)
  • Conventions :
    CF-1.0
    Info :
    Monthly ERA-Interim data. Downloaded and edited by fabien.maussion@uibk.ac.at
  • " ], "text/plain": [ "\n", @@ -3305,7 +3288,7 @@ " Info: Monthly ERA-Interim data. Downloaded and edited by fabien.m..." ] }, - "execution_count": 9, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -3337,7 +3320,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -3707,21 +3690,21 @@ " fill: currentColor;\n", "}\n", "
    <xarray.Dataset>\n",
    -       "Dimensions:         (level: 3, month: 2, world_polygons: 127)\n",
    +       "Dimensions:         (level: 3, world_polygons: 127, month: 2)\n",
            "Coordinates:\n",
            "  * level           (level) int32 200 500 850\n",
            "  * month           (month) int32 1 7\n",
            "  * world_polygons  (world_polygons) object POLYGON ((-59.57209469261153 -80....\n",
            "    index           (world_polygons) int64 0 1 2 3 4 5 ... 122 123 124 125 126\n",
            "Data variables:\n",
    -       "    z               (world_polygons, month, level) float64 1.1e+05 ... 1.394e+04\n",
    -       "    u               (world_polygons, month, level) float64 2.401 ... 0.8898\n",
    -       "    v               (world_polygons, month, level) float64 0.4296 ... 0.6399\n",
    +       "    z               (world_polygons, month, level) float64 1.1e+05 ... 1.393e+04\n",
    +       "    u               (world_polygons, month, level) float64 2.345 ... 0.8456\n",
    +       "    v               (world_polygons, month, level) float64 0.4407 ... 0.5869\n",
            "Indexes:\n",
            "    world_polygons  GeometryIndex (crs=EPSG:4326)\n",
            "Attributes:\n",
            "    Conventions:  CF-1.0\n",
    -       "    Info:         Monthly ERA-Interim data. Downloaded and edited by fabien.m...
    • level
      PandasIndex
      PandasIndex(Index([200, 500, 850], dtype='int32', name='level'))
    • month
      PandasIndex
      PandasIndex(Index([1, 7], dtype='int32', name='month'))
    • world_polygons
      GeometryIndex (crs=EPSG:4326)
      GeometryIndex(\n",
      +       "    [<POLYGON ((-59.572 -80.04, -59.866 -80.55, -60.16 -81, -62.255 -80.863, -64....>\n",
      +       "     <POLYGON ((-159.208 -79.497, -161.128 -79.634, -162.44 -79.281, -163.027 -78...>\n",
      +       "     <POLYGON ((-45.155 -78.047, -43.921 -78.478, -43.49 -79.086, -43.372 -79.517...>\n",
      +       "     <POLYGON ((-121.212 -73.501, -119.919 -73.658, -118.724 -73.481, -119.292 -7...>\n",
      +       "     ...\n",
      +       "     <POLYGON ((99.94 78.881, 97.758 78.756, 94.973 79.045, 93.313 79.427, 92.545...>\n",
      +       "     <POLYGON ((-87.02 79.66, -85.814 79.337, -87.188 79.039, -89.035 78.287, -90...>\n",
      +       "     <POLYGON ((-68.5 83.106, -65.827 83.028, -63.68 82.9, -61.85 82.629, -61.894...>\n",
      +       "     <POLYGON ((-27.1 83.52, -20.845 82.727, -22.692 82.342, -26.518 82.298, -31....>],\n",
      +       "    crs=EPSG:4326)
  • Conventions :
    CF-1.0
    Info :
    Monthly ERA-Interim data. Downloaded and edited by fabien.maussion@uibk.ac.at
  • " ], "text/plain": [ "\n", - "Dimensions: (level: 3, month: 2, world_polygons: 127)\n", + "Dimensions: (level: 3, world_polygons: 127, month: 2)\n", "Coordinates:\n", " * level (level) int32 200 500 850\n", " * month (month) int32 1 7\n", " * world_polygons (world_polygons) object POLYGON ((-59.57209469261153 -80....\n", " index (world_polygons) int64 0 1 2 3 4 5 ... 122 123 124 125 126\n", "Data variables:\n", - " z (world_polygons, month, level) float64 1.1e+05 ... 1.394e+04\n", - " u (world_polygons, month, level) float64 2.401 ... 0.8898\n", - " v (world_polygons, month, level) float64 0.4296 ... 0.6399\n", + " z (world_polygons, month, level) float64 1.1e+05 ... 1.393e+04\n", + " u (world_polygons, month, level) float64 2.345 ... 0.8456\n", + " v (world_polygons, month, level) float64 0.4407 ... 0.5869\n", "Indexes:\n", " world_polygons GeometryIndex (crs=EPSG:4326)\n", "Attributes:\n", @@ -3998,7 +3991,7 @@ " Info: Monthly ERA-Interim data. Downloaded and edited by fabien.m..." ] }, - "execution_count": 12, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -4029,7 +4022,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -4412,7 +4405,7 @@ " geometry GeometryIndex (crs=EPSG:4326)\n", "Attributes:\n", " Conventions: CF-1.0\n", - " Info: Monthly ERA-Interim data. Downloaded and edited by fabien.m...
    • level
      PandasIndex
      PandasIndex(Index([200, 500, 850], dtype='int32', name='level'))
    • month
      PandasIndex
      PandasIndex(Index([1, 7], dtype='int32', name='month'))
    • geometry
      GeometryIndex (crs=EPSG:4326)
      GeometryIndex(\n",
      +       "    [<POLYGON ((-59.572 -80.04, -59.866 -80.55, -60.16 -81, -62.255 -80.863, -64....>\n",
      +       "     <POLYGON ((-159.208 -79.497, -161.128 -79.634, -162.44 -79.281, -163.027 -78...>\n",
      +       "     <POLYGON ((-45.155 -78.047, -43.921 -78.478, -43.49 -79.086, -43.372 -79.517...>\n",
      +       "     <POLYGON ((-121.212 -73.501, -119.919 -73.658, -118.724 -73.481, -119.292 -7...>\n",
      +       "     ...\n",
      +       "     <POLYGON ((99.94 78.881, 97.758 78.756, 94.973 79.045, 93.313 79.427, 92.545...>\n",
      +       "     <POLYGON ((-87.02 79.66, -85.814 79.337, -87.188 79.039, -89.035 78.287, -90...>\n",
      +       "     <POLYGON ((-68.5 83.106, -65.827 83.028, -63.68 82.9, -61.85 82.629, -61.894...>\n",
      +       "     <POLYGON ((-27.1 83.52, -20.845 82.727, -22.692 82.342, -26.518 82.298, -31....>],\n",
      +       "    crs=EPSG:4326)
  • Conventions :
    CF-1.0
    Info :
    Monthly ERA-Interim data. Downloaded and edited by fabien.maussion@uibk.ac.at
  • " ], "text/plain": [ "\n", @@ -4679,7 +4682,7 @@ " Info: Monthly ERA-Interim data. Downloaded and edited by fabien.m..." ] }, - "execution_count": 13, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -4712,7 +4715,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -4742,7 +4745,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -5123,7 +5126,7 @@ " spatial_ref int64 0\n", " * zonal_statistics (zonal_statistics) <U4 'mean' 'min' 'max' 'std'\n", " * geometry (geometry) object MULTIPOLYGON (((-90.59735248065536 41...\n", - " mukey (geometry) object '271425' '198692' ... '198750' '198724'\n", + " index (geometry) int64 0 11 22 33 44 55 66\n", "Indexes:\n", " geometry GeometryIndex (crs=EPSG:4269)\n", "Attributes:\n", @@ -5134,21 +5137,28 @@ " RepresentationType: *\n", " scale_factor: 1.0\n", " add_offset: 0.0\n", - " long_name: Layer_1
    • zonal_statistics
      PandasIndex
      PandasIndex(Index(['mean', 'min', 'max', 'std'], dtype='object', name='zonal_statistics'))
    • geometry
      GeometryIndex (crs=EPSG:4269)
      GeometryIndex(\n",
      +       "    [<MULTIPOLYGON (((-90.597 41.493, -90.597 41.492, -90.597 41.492, -90.597 41....>\n",
      +       "     <MULTIPOLYGON (((-90.595 41.487, -90.595 41.487, -90.595 41.487, -90.594 41....>\n",
      +       "     <MULTIPOLYGON (((-90.593 41.5, -90.593 41.5, -90.593 41.499, -90.593 41.499,...>\n",
      +       "     <MULTIPOLYGON (((-90.591 41.496, -90.591 41.496, -90.59 41.496, -90.59 41.49...>\n",
      +       "     <MULTIPOLYGON (((-90.592 41.495, -90.592 41.495, -90.591 41.495, -90.591 41....>\n",
      +       "     <MULTIPOLYGON (((-90.597 41.493, -90.597 41.493, -90.597 41.493, -90.597 41....>\n",
      +       "     <MULTIPOLYGON (((-90.586 41.483, -90.586 41.484, -90.586 41.484, -90.585 41....>],\n",
      +       "    crs=EPSG:4269)
  • AREA_OR_POINT :
    Area
    BandDefinitionKeyword :
    *
    DataType :
    *
    LAYER_TYPE :
    athematic
    RepresentationType :
    *
    scale_factor :
    1.0
    add_offset :
    0.0
    long_name :
    Layer_1
  • " ], "text/plain": [ "\n", @@ -5163,7 +5173,7 @@ " spatial_ref int64 0\n", " * zonal_statistics (zonal_statistics) Date: Mon, 22 Apr 2024 20:47:40 +0200 Subject: [PATCH 3/3] backwards compat --- xvec/index.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xvec/index.py b/xvec/index.py index c10c83d..a05b632 100644 --- a/xvec/index.py +++ b/xvec/index.py @@ -286,6 +286,7 @@ def __repr__(self) -> str: if len(wkts) == 1: return f"GeometryIndex([{wkts[0]}], crs={srs})" - return f"GeometryIndex(\n[{wkts[0]}\n {'\n '.join(wkts[1:])}],\ncrs={srs})".replace( + joined = "\n ".join(wkts[1:]) + return f"GeometryIndex(\n[{wkts[0]}\n {joined}],\ncrs={srs})".replace( "\n", "\n" + " " * 4 )