diff --git a/drafts/stackstac-ncdf.ipynb b/drafts/stackstac-ncdf.ipynb new file mode 100644 index 0000000..232023c --- /dev/null +++ b/drafts/stackstac-ncdf.ipynb @@ -0,0 +1,839 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 6, + "id": "9e2c81a0-5602-40be-ba03-42675ce42c1f", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import stackstac\n", + "from pystac_client import Client\n", + "from stackstac.rio_env import LayeredEnv\n", + "\n", + "# ensure we have an earthdata .netrc set, and also need cookie file:\n", + "import os\n", + "from pathlib import Path\n", + "cookies = os.path.expanduser(\"~/.urs_cookies\")\n", + "Path(cookies).touch()" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "cb21b345-bc6e-4819-9149-9a233f548081", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/jovyan/.virtualenvs/spatial/lib/python3.10/site-packages/stackstac/prepare.py:408: UserWarning: The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n", + " times = pd.to_datetime(\n" + ] + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
<xarray.DataArray 'stackstac-3893b89144636d9866bc23c4325591b8' (time: 1,\n",
+       "                                                                band: 1,\n",
+       "                                                                y: 18000,\n",
+       "                                                                x: 36000)>\n",
+       "dask.array<fetch_raster_window, shape=(1, 1, 18000, 36000), dtype=float64, chunksize=(1, 1, 1024, 1024), chunktype=numpy.ndarray>\n",
+       "Coordinates:\n",
+       "  * time            (time) datetime64[ns] 2019-12-31T21:00:00\n",
+       "    id              (time) <U57 '20200101090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB...\n",
+       "  * band            (band) <U4 'data'\n",
+       "  * x               (x) float64 -180.0 -180.0 -180.0 ... 180.0 180.0 180.0\n",
+       "  * y               (y) float64 90.0 89.99 89.98 89.97 ... -89.97 -89.98 -89.99\n",
+       "    start_datetime  <U24 '2019-12-31T21:00:00.000Z'\n",
+       "    end_datetime    <U24 '2020-01-01T21:00:00.000Z'\n",
+       "    title           <U69 'Download 20200101090000-JPL-L4_GHRSST-SSTfnd-MUR-GL...\n",
+       "    epsg            int64 4326\n",
+       "Attributes:\n",
+       "    spec:        RasterSpec(epsg=4326, bounds=(-180.0, -90.0, 180.0, 90.0), r...\n",
+       "    crs:         epsg:4326\n",
+       "    transform:   | 0.01, 0.00,-180.00|\\n| 0.00,-0.01, 90.00|\\n| 0.00, 0.00, 1...\n",
+       "    resolution:  0.01
" + ], + "text/plain": [ + "\n", + "dask.array\n", + "Coordinates:\n", + " * time (time) datetime64[ns] 2019-12-31T21:00:00\n", + " id (time) \n", + "\n", + "I'm basing this on the part of the error shown below that goes like:\n", + "\n", + "```\n", + "File ~/.virtualenvs/spatial/lib/python3.10/site-packages/stackstac/rio_reader.py:340, in AutoParallelRioReader._open(self)\n", + " 337 if ds.count != 1:\n", + " 338 ds.close()\n", + " 339 raise RuntimeError(\n", + "--> 340 f\"Assets must have exactly 1 band, but file {self.url!r} has {ds.count}. \"\n", + " 341 \"We can't currently handle multi-band rasters (each band has to be \"\n", + " 342 \"a separate STAC asset), so you'll need to exclude this asset from your analysis.\"\n", + " 343 )\n", + "```\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "4f18cdc9-7aaf-4072-9723-b874cee1e7d9", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/jovyan/.virtualenvs/spatial/lib/python3.10/site-packages/stackstac/rio_reader.py:327: NotGeoreferencedWarning: Dataset has no geotransform, gcps, or rpcs. The identity matrix will be returned.\n", + " ds = SelfCleaningDatasetReader(self.url, sharing=False)\n" + ] + }, + { + "ename": "ValueError", + "evalue": "Can't read closed raster file", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[10], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mdata\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mvalues\u001b[49m()[\u001b[38;5;241m0\u001b[39m]\n", + "File \u001b[0;32m~/.virtualenvs/spatial/lib/python3.10/site-packages/xarray/core/dataarray.py:757\u001b[0m, in \u001b[0;36mDataArray.values\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 748\u001b[0m \u001b[38;5;129m@property\u001b[39m\n\u001b[1;32m 749\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mvalues\u001b[39m(\u001b[38;5;28mself\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m np\u001b[38;5;241m.\u001b[39mndarray:\n\u001b[1;32m 750\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 751\u001b[0m \u001b[38;5;124;03m The array's data as a numpy.ndarray.\u001b[39;00m\n\u001b[1;32m 752\u001b[0m \n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 755\u001b[0m \u001b[38;5;124;03m type does not support coercion like this (e.g. cupy).\u001b[39;00m\n\u001b[1;32m 756\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m--> 757\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mvariable\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mvalues\u001b[49m\n", + "File \u001b[0;32m~/.virtualenvs/spatial/lib/python3.10/site-packages/xarray/core/variable.py:606\u001b[0m, in \u001b[0;36mVariable.values\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 603\u001b[0m \u001b[38;5;129m@property\u001b[39m\n\u001b[1;32m 604\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mvalues\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[1;32m 605\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"The variable's data as a numpy.ndarray\"\"\"\u001b[39;00m\n\u001b[0;32m--> 606\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_as_array_or_item\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_data\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m~/.virtualenvs/spatial/lib/python3.10/site-packages/xarray/core/variable.py:306\u001b[0m, in \u001b[0;36m_as_array_or_item\u001b[0;34m(data)\u001b[0m\n\u001b[1;32m 292\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_as_array_or_item\u001b[39m(data):\n\u001b[1;32m 293\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Return the given values as a numpy array, or as an individual item if\u001b[39;00m\n\u001b[1;32m 294\u001b[0m \u001b[38;5;124;03m it's a 0d datetime64 or timedelta64 array.\u001b[39;00m\n\u001b[1;32m 295\u001b[0m \n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 304\u001b[0m \u001b[38;5;124;03m TODO: remove this (replace with np.asarray) once these issues are fixed\u001b[39;00m\n\u001b[1;32m 305\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m--> 306\u001b[0m data \u001b[38;5;241m=\u001b[39m \u001b[43mnp\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43masarray\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdata\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 307\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m data\u001b[38;5;241m.\u001b[39mndim \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m0\u001b[39m:\n\u001b[1;32m 308\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m data\u001b[38;5;241m.\u001b[39mdtype\u001b[38;5;241m.\u001b[39mkind \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mM\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n", + "File \u001b[0;32m~/.virtualenvs/spatial/lib/python3.10/site-packages/dask/array/core.py:1700\u001b[0m, in \u001b[0;36mArray.__array__\u001b[0;34m(self, dtype, **kwargs)\u001b[0m\n\u001b[1;32m 1699\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m__array__\u001b[39m(\u001b[38;5;28mself\u001b[39m, dtype\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[0;32m-> 1700\u001b[0m x \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcompute\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1701\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m dtype \u001b[38;5;129;01mand\u001b[39;00m x\u001b[38;5;241m.\u001b[39mdtype \u001b[38;5;241m!=\u001b[39m dtype:\n\u001b[1;32m 1702\u001b[0m x \u001b[38;5;241m=\u001b[39m x\u001b[38;5;241m.\u001b[39mastype(dtype)\n", + "File \u001b[0;32m~/.virtualenvs/spatial/lib/python3.10/site-packages/dask/base.py:342\u001b[0m, in \u001b[0;36mDaskMethodsMixin.compute\u001b[0;34m(self, **kwargs)\u001b[0m\n\u001b[1;32m 318\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mcompute\u001b[39m(\u001b[38;5;28mself\u001b[39m, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m 319\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Compute this dask collection\u001b[39;00m\n\u001b[1;32m 320\u001b[0m \n\u001b[1;32m 321\u001b[0m \u001b[38;5;124;03m This turns a lazy Dask collection into its in-memory equivalent.\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 340\u001b[0m \u001b[38;5;124;03m dask.compute\u001b[39;00m\n\u001b[1;32m 341\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m--> 342\u001b[0m (result,) \u001b[38;5;241m=\u001b[39m \u001b[43mcompute\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtraverse\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 343\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m result\n", + "File \u001b[0;32m~/.virtualenvs/spatial/lib/python3.10/site-packages/dask/base.py:628\u001b[0m, in \u001b[0;36mcompute\u001b[0;34m(traverse, optimize_graph, scheduler, get, *args, **kwargs)\u001b[0m\n\u001b[1;32m 625\u001b[0m postcomputes\u001b[38;5;241m.\u001b[39mappend(x\u001b[38;5;241m.\u001b[39m__dask_postcompute__())\n\u001b[1;32m 627\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m shorten_traceback():\n\u001b[0;32m--> 628\u001b[0m results \u001b[38;5;241m=\u001b[39m \u001b[43mschedule\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdsk\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkeys\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 630\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m repack([f(r, \u001b[38;5;241m*\u001b[39ma) \u001b[38;5;28;01mfor\u001b[39;00m r, (f, a) \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mzip\u001b[39m(results, postcomputes)])\n", + "File \u001b[0;32m~/.virtualenvs/spatial/lib/python3.10/site-packages/stackstac/to_dask.py:189\u001b[0m, in \u001b[0;36mfetch_raster_window\u001b[0;34m(reader_table, slices, dtype, fill_value)\u001b[0m\n\u001b[1;32m 182\u001b[0m \u001b[38;5;66;03m# Only read if the window we're fetching actually overlaps with the asset\u001b[39;00m\n\u001b[1;32m 183\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m windows\u001b[38;5;241m.\u001b[39mintersect(current_window, asset_window):\n\u001b[1;32m 184\u001b[0m \u001b[38;5;66;03m# NOTE: when there are multiple assets, we _could_ parallelize these reads with our own threadpool.\u001b[39;00m\n\u001b[1;32m 185\u001b[0m \u001b[38;5;66;03m# However, that would probably increase memory usage, since the internal, thread-local GDAL datasets\u001b[39;00m\n\u001b[1;32m 186\u001b[0m \u001b[38;5;66;03m# would end up copied to even more threads.\u001b[39;00m\n\u001b[1;32m 187\u001b[0m \n\u001b[1;32m 188\u001b[0m \u001b[38;5;66;03m# TODO when the Reader won't be rescaling, support passing `output` to avoid the copy?\u001b[39;00m\n\u001b[0;32m--> 189\u001b[0m data \u001b[38;5;241m=\u001b[39m \u001b[43mreader\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcurrent_window\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 191\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m all_empty:\n\u001b[1;32m 192\u001b[0m \u001b[38;5;66;03m# Turn `output` from a broadcast-trick array to a real array, so it's writeable\u001b[39;00m\n\u001b[1;32m 193\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m (\n\u001b[1;32m 194\u001b[0m np\u001b[38;5;241m.\u001b[39misnan(data)\n\u001b[1;32m 195\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m np\u001b[38;5;241m.\u001b[39misnan(fill_value)\n\u001b[1;32m 196\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m np\u001b[38;5;241m.\u001b[39mequal(data, fill_value)\n\u001b[1;32m 197\u001b[0m )\u001b[38;5;241m.\u001b[39mall():\n\u001b[1;32m 198\u001b[0m \u001b[38;5;66;03m# Unless the data we just read is all empty anyway\u001b[39;00m\n", + "File \u001b[0;32m~/.virtualenvs/spatial/lib/python3.10/site-packages/stackstac/rio_reader.py:385\u001b[0m, in \u001b[0;36mAutoParallelRioReader.read\u001b[0;34m(self, window, **kwargs)\u001b[0m\n\u001b[1;32m 384\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mread\u001b[39m(\u001b[38;5;28mself\u001b[39m, window: Window, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m np\u001b[38;5;241m.\u001b[39mndarray:\n\u001b[0;32m--> 385\u001b[0m reader \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdataset\u001b[49m\n\u001b[1;32m 386\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 387\u001b[0m result \u001b[38;5;241m=\u001b[39m reader\u001b[38;5;241m.\u001b[39mread(\n\u001b[1;32m 388\u001b[0m window\u001b[38;5;241m=\u001b[39mwindow,\n\u001b[1;32m 389\u001b[0m out_dtype\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdtype,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 393\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs,\n\u001b[1;32m 394\u001b[0m )\n", + "File \u001b[0;32m~/.virtualenvs/spatial/lib/python3.10/site-packages/stackstac/rio_reader.py:381\u001b[0m, in \u001b[0;36mAutoParallelRioReader.dataset\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 379\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_dataset_lock:\n\u001b[1;32m 380\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_dataset \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m--> 381\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_dataset \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_open\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 382\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_dataset\n", + "File \u001b[0;32m~/.virtualenvs/spatial/lib/python3.10/site-packages/stackstac/rio_reader.py:340\u001b[0m, in \u001b[0;36mAutoParallelRioReader._open\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 337\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m ds\u001b[38;5;241m.\u001b[39mcount \u001b[38;5;241m!=\u001b[39m \u001b[38;5;241m1\u001b[39m:\n\u001b[1;32m 338\u001b[0m ds\u001b[38;5;241m.\u001b[39mclose()\n\u001b[1;32m 339\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mRuntimeError\u001b[39;00m(\n\u001b[0;32m--> 340\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAssets must have exactly 1 band, but file \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39murl\u001b[38;5;132;01m!r}\u001b[39;00m\u001b[38;5;124m has \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[43mds\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcount\u001b[49m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m. \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 341\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mWe can\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mt currently handle multi-band rasters (each band has to be \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 342\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124ma separate STAC asset), so you\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mll need to exclude this asset from your analysis.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 343\u001b[0m )\n\u001b[1;32m 345\u001b[0m \u001b[38;5;66;03m# Only make a VRT if the dataset doesn't match the spatial spec we want\u001b[39;00m\n\u001b[1;32m 346\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mspec\u001b[38;5;241m.\u001b[39mvrt_params \u001b[38;5;241m!=\u001b[39m {\n\u001b[1;32m 347\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcrs\u001b[39m\u001b[38;5;124m\"\u001b[39m: ds\u001b[38;5;241m.\u001b[39mcrs\u001b[38;5;241m.\u001b[39mto_epsg(),\n\u001b[1;32m 348\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtransform\u001b[39m\u001b[38;5;124m\"\u001b[39m: ds\u001b[38;5;241m.\u001b[39mtransform,\n\u001b[1;32m 349\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mheight\u001b[39m\u001b[38;5;124m\"\u001b[39m: ds\u001b[38;5;241m.\u001b[39mheight,\n\u001b[1;32m 350\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mwidth\u001b[39m\u001b[38;5;124m\"\u001b[39m: ds\u001b[38;5;241m.\u001b[39mwidth,\n\u001b[1;32m 351\u001b[0m }:\n", + "File \u001b[0;32mrasterio/_base.pyx:476\u001b[0m, in \u001b[0;36mrasterio._base.DatasetBase.count.__get__\u001b[0;34m()\u001b[0m\n", + "\u001b[0;31mValueError\u001b[0m: Can't read closed raster file" + ] + } + ], + "source": [ + "data.values()[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "c3ec3ba0-2423-4f6b-b4db-002742a0d9c8", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "rasterio info:\n", + " rasterio: 1.3.8\n", + " GDAL: 3.6.4\n", + " PROJ: 9.0.1\n", + " GEOS: 3.11.1\n", + " PROJ DATA: /srv/conda/envs/notebook/share/proj\n", + " GDAL DATA: /srv/conda/envs/notebook/share/gdal\n", + "\n", + "System:\n", + " python: 3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:40:32) [GCC 12.3.0]\n", + "executable: /home/jovyan/.virtualenvs/spatial/bin/python\n", + " machine: Linux-6.5.6-76060506-generic-x86_64-with-glibc2.35\n", + "\n", + "Python deps:\n", + " affine: 2.4.0\n", + " attrs: 23.1.0\n", + " certifi: 2023.07.22\n", + " click: 8.1.7\n", + " cligj: 0.7.2\n", + " cython: None\n", + " numpy: 1.26.0\n", + " snuggs: 1.4.7\n", + "click-plugins: None\n", + "setuptools: 65.5.0\n" + ] + } + ], + "source": [ + "import rasterio\n", + "rasterio.show_versions()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "spatial", + "language": "python", + "name": "spatial" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}