From 9f60d9e808a30b3727233b1f21d6a73186ce2e61 Mon Sep 17 00:00:00 2001 From: Sean Gillies Date: Fri, 25 Mar 2022 09:36:52 -0600 Subject: [PATCH 1/3] No need to copy the meta or profile attributes I'm not sure how this usage spread, it's never been necessary to do this. The meta and profile attributes of a dataset are already copies of what is in the dataset. Modifying them does not modify the dataset. --- source/notebooks/L5/clipping-raster.ipynb | 28 +---------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/source/notebooks/L5/clipping-raster.ipynb b/source/notebooks/L5/clipping-raster.ipynb index 3ee4d56..8fd775d 100644 --- a/source/notebooks/L5/clipping-raster.ipynb +++ b/source/notebooks/L5/clipping-raster.ipynb @@ -227,33 +227,6 @@ "out_img, out_transform = mask(dataset=data, shapes=coords, crop=True)" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Next, we need to modify the metadata. Let's start by copying the metadata from the original data file." - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'driver': 'GTiff', 'dtype': 'uint8', 'nodata': None, 'width': 8877, 'height': 8106, 'count': 7, 'crs': CRS({'init': 'epsg:32634'}), 'transform': Affine(28.5, 0.0, 600466.5,\n", - " 0.0, -28.5, 6784966.5)}\n" - ] - } - ], - "source": [ - "# Copy the metadata\n", - "out_meta = data.meta.copy()\n", - "print(out_meta)" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -293,6 +266,7 @@ "metadata": {}, "outputs": [], "source": [ + "out_meta = data.profile "out_meta.update({\"driver\": \"GTiff\",\n", " \"height\": out_img.shape[1],\n", " \"width\": out_img.shape[2],\n", From 50cb3f43b3c7246528a92c888b83d6cd2f942c0f Mon Sep 17 00:00:00 2001 From: Sean Gillies Date: Fri, 25 Mar 2022 09:38:28 -0600 Subject: [PATCH 2/3] Fix JSON --- source/notebooks/L5/clipping-raster.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/notebooks/L5/clipping-raster.ipynb b/source/notebooks/L5/clipping-raster.ipynb index 8fd775d..1de75b0 100644 --- a/source/notebooks/L5/clipping-raster.ipynb +++ b/source/notebooks/L5/clipping-raster.ipynb @@ -266,7 +266,7 @@ "metadata": {}, "outputs": [], "source": [ - "out_meta = data.profile + "out_meta = data.profile", "out_meta.update({\"driver\": \"GTiff\",\n", " \"height\": out_img.shape[1],\n", " \"width\": out_img.shape[2],\n", From 07608971f4c4d2c7d9c7488b9e3e7ae2df614ae1 Mon Sep 17 00:00:00 2001 From: Sean Gillies Date: Fri, 25 Mar 2022 09:39:49 -0600 Subject: [PATCH 3/3] Add newline --- source/notebooks/L5/clipping-raster.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/notebooks/L5/clipping-raster.ipynb b/source/notebooks/L5/clipping-raster.ipynb index 1de75b0..8c97341 100644 --- a/source/notebooks/L5/clipping-raster.ipynb +++ b/source/notebooks/L5/clipping-raster.ipynb @@ -266,7 +266,7 @@ "metadata": {}, "outputs": [], "source": [ - "out_meta = data.profile", + "out_meta = data.profile\n", "out_meta.update({\"driver\": \"GTiff\",\n", " \"height\": out_img.shape[1],\n", " \"width\": out_img.shape[2],\n",