From c9abbddce2e6445eeddfdf3609f450efb19836c9 Mon Sep 17 00:00:00 2001 From: Zoltan Sylvester Date: Wed, 18 Dec 2024 12:32:22 -0600 Subject: [PATCH] update georeferencing notebook --- ...Segment_every_grain_w_georeferencing.ipynb | 620 ++++++++++++------ 1 file changed, 422 insertions(+), 198 deletions(-) diff --git a/segmenteverygrain/Segment_every_grain_w_georeferencing.ipynb b/segmenteverygrain/Segment_every_grain_w_georeferencing.ipynb index 9380cd5..2b0bc01 100644 --- a/segmenteverygrain/Segment_every_grain_w_georeferencing.ipynb +++ b/segmenteverygrain/Segment_every_grain_w_georeferencing.ipynb @@ -4,32 +4,46 @@ "cell_type": "markdown", "id": "95a8f02b", "metadata": { - "jp-MarkdownHeadingCollapsed": true, "tags": [] }, "source": [ "## Import packages" ] }, + { + "cell_type": "markdown", + "id": "360fd114-4a50-4a7d-8fa2-357867cbd601", + "metadata": {}, + "source": [ + "Noet that `rasterio` and `geopandas` need to be installed in the current Python environment for this notebook to work." + ] + }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "id": "f2ebc518", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-12-18T17:56:18.168629Z", + "iopub.status.busy": "2024-12-18T17:56:18.167941Z", + "iopub.status.idle": "2024-12-18T17:56:22.138277Z", + "shell.execute_reply": "2024-12-18T17:56:22.137831Z", + "shell.execute_reply.started": "2024-12-18T17:56:18.168575Z" + } + }, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import cv2\n", - "from skimage import measure\n", "from skimage.measure import regionprops, regionprops_table\n", - "from tensorflow.keras.optimizers.legacy import Adam\n", - "from tensorflow.keras.preprocessing.image import load_img\n", + "from keras.utils import load_img\n", + "from keras.saving import load_model\n", "from importlib import reload\n", "import segmenteverygrain as seg\n", - "from segment_anything import sam_model_registry, SamAutomaticMaskGenerator, SamPredictor\n", - "from tqdm import trange\n", + "from segment_anything import sam_model_registry, SamPredictor\n", + "from tqdm import trange, tqdm\n", "%matplotlib qt" ] }, @@ -37,7 +51,6 @@ "cell_type": "markdown", "id": "f474ac20", "metadata": { - "jp-MarkdownHeadingCollapsed": true, "tags": [] }, "source": [ @@ -46,31 +59,34 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "id": "fe1bd2bc", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-12-18T17:56:31.965227Z", + "iopub.status.busy": "2024-12-18T17:56:31.963816Z", + "iopub.status.idle": "2024-12-18T17:56:34.544967Z", + "shell.execute_reply": "2024-12-18T17:56:34.544481Z", + "shell.execute_reply.started": "2024-12-18T17:56:31.965175Z" + } + }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "2024-03-28 11:40:06.554885: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:305] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support.\n", - "2024-03-28 11:40:06.555069: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:271] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 0 MB memory) -> physical PluggableDevice (device: 0, name: METAL, pci bus id: )\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Metal device set to: Apple M2 Max\n" + "2024-12-18 11:56:31.978965: I metal_plugin/src/device/metal_device.cc:1154] Metal device set to: Apple M2 Max\n", + "2024-12-18 11:56:31.979033: I metal_plugin/src/device/metal_device.cc:296] systemMemory: 96.00 GB\n", + "2024-12-18 11:56:31.979042: I metal_plugin/src/device/metal_device.cc:313] maxCacheSize: 36.00 GB\n", + "2024-12-18 11:56:31.979092: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:305] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support.\n", + "2024-12-18 11:56:31.979145: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:271] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 0 MB memory) -> physical PluggableDevice (device: 0, name: METAL, pci bus id: )\n", + "/Users/zoltan/miniforge3/envs/segmenteverygrain/lib/python3.9/site-packages/segment_anything/build_sam.py:105: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.\n", + " state_dict = torch.load(f)\n" ] } ], "source": [ - "model = seg.Unet()\n", - "model.compile(optimizer=Adam(), loss=seg.weighted_crossentropy, metrics=[\"accuracy\"])\n", - "# you need to download the 'segmenteverygrain' model for this to work ()\n", - "model.load_weights('./checkpoints/seg_model');\n", + "model = load_model(\"seg_model.keras\", custom_objects={'weighted_crossentropy': seg.weighted_crossentropy})\n", "\n", "# the SAM model checkpoints can be downloaded from: https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth\n", "sam = sam_model_registry[\"default\"](checkpoint=\"/Users/zoltan/Dropbox/Segmentation/sam_vit_h_4b8939.pth\")" @@ -92,34 +108,108 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "id": "94bf3f94", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-12-18T17:56:43.912057Z", + "iopub.status.busy": "2024-12-18T17:56:43.911552Z", + "iopub.status.idle": "2024-12-18T17:57:57.879489Z", + "shell.execute_reply": "2024-12-18T17:57:57.879003Z", + "shell.execute_reply.started": "2024-12-18T17:56:43.912023Z" + } + }, "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "segmenting image tiles...\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + " 0%| | 0/6 [00:00" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 26, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "all_grains[10]" + "all_grains, labels, mask_all = seg.get_grains_from_patches(ax, image)" ] }, { @@ -578,10 +711,9 @@ "metadata": {}, "outputs": [], "source": [ - "plt.figure()\n", - "plt.hist(grain_data['major_axis_length'], 25)\n", - "plt.xlabel('major axis length (microns)')\n", - "plt.ylabel('count');" + "# plot histogram of grain axis lengths\n", + "# note that input data needs to be in milimeters\n", + "fig, ax = seg.plot_histogram_of_axis_lengths(grain_data['major_axis_length'], grain_data['minor_axis_length'], binsize=0.2, xlimits=[0.25, 4])" ] }, { @@ -631,9 +763,17 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 24, "id": "16c934cc", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-12-18T18:12:01.069850Z", + "iopub.status.busy": "2024-12-18T18:12:01.069331Z", + "iopub.status.idle": "2024-12-18T18:12:01.120071Z", + "shell.execute_reply": "2024-12-18T18:12:01.119391Z", + "shell.execute_reply.started": "2024-12-18T18:12:01.069807Z" + } + }, "outputs": [], "source": [ "import rasterio\n", @@ -642,9 +782,17 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 25, "id": "d0577a80", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-12-18T18:12:02.984118Z", + "iopub.status.busy": "2024-12-18T18:12:02.983605Z", + "iopub.status.idle": "2024-12-18T18:12:02.991710Z", + "shell.execute_reply": "2024-12-18T18:12:02.990284Z", + "shell.execute_reply.started": "2024-12-18T18:12:02.984084Z" + } + }, "outputs": [ { "data": { @@ -655,12 +803,12 @@ " 'width': 1113,\n", " 'height': 1112,\n", " 'count': 4,\n", - " 'crs': CRS.from_epsg(32619),\n", + " 'crs': CRS.from_wkt('PROJCS[\"WGS 84 / UTM zone 19N\",GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",-69],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH],AUTHORITY[\"EPSG\",\"32619\"]]'),\n", " 'transform': Affine(0.0017999999999882017, 0.0, 339041.9403932594,\n", " 0.0, -0.0018000000000683416, 4686358.8424565075)}" ] }, - "execution_count": 5, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } @@ -671,9 +819,17 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 26, "id": "26b2fc5b", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-12-18T18:12:07.123107Z", + "iopub.status.busy": "2024-12-18T18:12:07.121901Z", + "iopub.status.idle": "2024-12-18T18:12:07.231305Z", + "shell.execute_reply": "2024-12-18T18:12:07.230847Z", + "shell.execute_reply.started": "2024-12-18T18:12:07.123033Z" + } + }, "outputs": [], "source": [ "# convert polygon coordinates from row, col to UTM\n", @@ -687,9 +843,17 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 28, "id": "13746f7b", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-12-18T18:14:46.865250Z", + "iopub.status.busy": "2024-12-18T18:14:46.864247Z", + "iopub.status.idle": "2024-12-18T18:14:48.882761Z", + "shell.execute_reply": "2024-12-18T18:14:48.882448Z", + "shell.execute_reply.started": "2024-12-18T18:14:46.865169Z" + } + }, "outputs": [ { "data": { @@ -718,23 +882,23 @@ " \n", " \n", " 0\n", - " POLYGON ((339043.428 4686358.675, 339043.426 4...\n", + " POLYGON ((339043.943 4686358.495, 339043.941 4...\n", " \n", " \n", " 1\n", - " POLYGON ((339042.953 4686357.667, 339042.951 4...\n", + " POLYGON ((339043.824 4686358.479, 339043.822 4...\n", " \n", " \n", " 2\n", - " POLYGON ((339042.181 4686357.410, 339042.179 4...\n", + " POLYGON ((339043.228 4686358.364, 339043.226 4...\n", " \n", " \n", " 3\n", - " POLYGON ((339042.022 4686357.336, 339042.020 4...\n", + " POLYGON ((339043.768 4686358.191, 339043.767 4...\n", " \n", " \n", " 4\n", - " POLYGON ((339043.865 4686357.228, 339043.864 4...\n", + " POLYGON ((339043.036 4686357.764, 339043.034 4...\n", " \n", " \n", "\n", @@ -742,14 +906,14 @@ ], "text/plain": [ " geometry\n", - "0 POLYGON ((339043.428 4686358.675, 339043.426 4...\n", - "1 POLYGON ((339042.953 4686357.667, 339042.951 4...\n", - "2 POLYGON ((339042.181 4686357.410, 339042.179 4...\n", - "3 POLYGON ((339042.022 4686357.336, 339042.020 4...\n", - "4 POLYGON ((339043.865 4686357.228, 339043.864 4..." + "0 POLYGON ((339043.943 4686358.495, 339043.941 4...\n", + "1 POLYGON ((339043.824 4686358.479, 339043.822 4...\n", + "2 POLYGON ((339043.228 4686358.364, 339043.226 4...\n", + "3 POLYGON ((339043.768 4686358.191, 339043.767 4...\n", + "4 POLYGON ((339043.036 4686357.764, 339043.034 4..." ] }, - "execution_count": 7, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } @@ -763,9 +927,17 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 30, "id": "548b71c0", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-12-18T18:14:55.426162Z", + "iopub.status.busy": "2024-12-18T18:14:55.425626Z", + "iopub.status.idle": "2024-12-18T18:14:55.517355Z", + "shell.execute_reply": "2024-12-18T18:14:55.516996Z", + "shell.execute_reply.started": "2024-12-18T18:14:55.426128Z" + } + }, "outputs": [ { "data": { @@ -800,69 +972,69 @@ " \n", " 0\n", " 1\n", - " 371\n", - " 78.140162\n", - " 826.512129\n", - " 26.579295\n", - " 18.273030\n", + " 683.0\n", + " 182.021962\n", + " 1097.698389\n", + " 37.846881\n", + " 24.424525\n", " \n", " \n", " 1\n", " 2\n", - " 987\n", - " 633.116515\n", - " 552.331307\n", - " 45.044539\n", - " 29.214000\n", + " 676.0\n", + " 189.627219\n", + " 1041.396450\n", + " 37.309940\n", + " 23.467704\n", " \n", " \n", " 2\n", " 3\n", - " 198\n", - " 786.873737\n", - " 131.095960\n", - " 18.471024\n", - " 13.888250\n", + " 410.0\n", + " 255.880488\n", + " 719.348780\n", + " 30.057850\n", + " 17.937276\n", " \n", " \n", " 3\n", " 4\n", - " 420\n", - " 821.252381\n", - " 41.250000\n", - " 30.301088\n", - " 18.403316\n", + " 393.0\n", + " 348.519084\n", + " 1015.414758\n", + " 29.249796\n", + " 19.877529\n", " \n", " \n", " 4\n", " 5\n", - " 812\n", - " 880.109606\n", - " 1069.188424\n", - " 38.886262\n", - " 27.357959\n", + " 354.0\n", + " 587.093220\n", + " 607.022599\n", + " 25.084603\n", + " 18.253541\n", " \n", " \n", "\n", "" ], "text/plain": [ - " label area centroid-0 centroid-1 major_axis_length minor_axis_length\n", - "0 1 371 78.140162 826.512129 26.579295 18.273030\n", - "1 2 987 633.116515 552.331307 45.044539 29.214000\n", - "2 3 198 786.873737 131.095960 18.471024 13.888250\n", - "3 4 420 821.252381 41.250000 30.301088 18.403316\n", - "4 5 812 880.109606 1069.188424 38.886262 27.357959" + " label area centroid-0 centroid-1 major_axis_length minor_axis_length\n", + "0 1 683.0 182.021962 1097.698389 37.846881 24.424525\n", + "1 2 676.0 189.627219 1041.396450 37.309940 23.467704\n", + "2 3 410.0 255.880488 719.348780 30.057850 17.937276\n", + "3 4 393.0 348.519084 1015.414758 29.249796 19.877529\n", + "4 5 354.0 587.093220 607.022599 25.084603 18.253541" ] }, - "execution_count": 8, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# create property dataframe from labeled image\n", - "props = regionprops_table(labels.astype('int'), intensity_image = big_im, properties =\\\n", + "props = regionprops_table(labels.astype('int'), intensity_image = image, properties =\\\n", " ('label', 'area', 'centroid', 'major_axis_length', 'minor_axis_length'))\n", "grain_data = pd.DataFrame(props)\n", "grain_data['major_axis_length'] = grain_data['major_axis_length'].values\n", @@ -873,9 +1045,17 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 31, "id": "552ca32c", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-12-18T18:14:58.866604Z", + "iopub.status.busy": "2024-12-18T18:14:58.865784Z", + "iopub.status.idle": "2024-12-18T18:14:58.875996Z", + "shell.execute_reply": "2024-12-18T18:14:58.875069Z", + "shell.execute_reply.started": "2024-12-18T18:14:58.866550Z" + } + }, "outputs": [], "source": [ "# convert centroids from row, col to UTM and add them to geodataframe\n", @@ -887,9 +1067,17 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 32, "id": "f1b8a302", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-12-18T18:15:00.711660Z", + "iopub.status.busy": "2024-12-18T18:15:00.711027Z", + "iopub.status.idle": "2024-12-18T18:15:00.729830Z", + "shell.execute_reply": "2024-12-18T18:15:00.729175Z", + "shell.execute_reply.started": "2024-12-18T18:15:00.711621Z" + } + }, "outputs": [ { "data": { @@ -922,43 +1110,43 @@ " \n", " \n", " 0\n", - " POLYGON ((339043.428 4686358.675, 339043.426 4...\n", - " 339043.429015\n", + " POLYGON ((339043.943 4686358.495, 339043.941 4...\n", + " 339043.917150\n", " 4.686359e+06\n", - " 0.047843\n", - " 0.032891\n", + " 0.068124\n", + " 0.043964\n", " \n", " \n", " 1\n", - " POLYGON ((339042.953 4686357.667, 339042.951 4...\n", - " 339042.935490\n", - " 4.686358e+06\n", - " 0.081080\n", - " 0.052585\n", + " POLYGON ((339043.824 4686358.479, 339043.822 4...\n", + " 339043.815807\n", + " 4.686359e+06\n", + " 0.067158\n", + " 0.042242\n", " \n", " \n", " 2\n", - " POLYGON ((339042.181 4686357.410, 339042.179 4...\n", - " 339042.177266\n", - " 4.686357e+06\n", - " 0.033248\n", - " 0.024999\n", + " POLYGON ((339043.228 4686358.364, 339043.226 4...\n", + " 339043.236121\n", + " 4.686358e+06\n", + " 0.054104\n", + " 0.032287\n", " \n", " \n", " 3\n", - " POLYGON ((339042.022 4686357.336, 339042.020 4...\n", - " 339042.015543\n", - " 4.686357e+06\n", - " 0.054542\n", - " 0.033126\n", + " POLYGON ((339043.768 4686358.191, 339043.767 4...\n", + " 339043.769040\n", + " 4.686358e+06\n", + " 0.052650\n", + " 0.035780\n", " \n", " \n", " 4\n", - " POLYGON ((339043.865 4686357.228, 339043.864 4...\n", - " 339043.865832\n", - " 4.686357e+06\n", - " 0.069995\n", - " 0.049244\n", + " POLYGON ((339043.036 4686357.764, 339043.034 4...\n", + " 339043.033934\n", + " 4.686358e+06\n", + " 0.045152\n", + " 0.032856\n", " \n", " \n", "\n", @@ -966,21 +1154,21 @@ ], "text/plain": [ " geometry centroid_x \\\n", - "0 POLYGON ((339043.428 4686358.675, 339043.426 4... 339043.429015 \n", - "1 POLYGON ((339042.953 4686357.667, 339042.951 4... 339042.935490 \n", - "2 POLYGON ((339042.181 4686357.410, 339042.179 4... 339042.177266 \n", - "3 POLYGON ((339042.022 4686357.336, 339042.020 4... 339042.015543 \n", - "4 POLYGON ((339043.865 4686357.228, 339043.864 4... 339043.865832 \n", + "0 POLYGON ((339043.943 4686358.495, 339043.941 4... 339043.917150 \n", + "1 POLYGON ((339043.824 4686358.479, 339043.822 4... 339043.815807 \n", + "2 POLYGON ((339043.228 4686358.364, 339043.226 4... 339043.236121 \n", + "3 POLYGON ((339043.768 4686358.191, 339043.767 4... 339043.769040 \n", + "4 POLYGON ((339043.036 4686357.764, 339043.034 4... 339043.033934 \n", "\n", " centroid_y major_axis_length minor_axis_length \n", - "0 4.686359e+06 0.047843 0.032891 \n", - "1 4.686358e+06 0.081080 0.052585 \n", - "2 4.686357e+06 0.033248 0.024999 \n", - "3 4.686357e+06 0.054542 0.033126 \n", - "4 4.686357e+06 0.069995 0.049244 " + "0 4.686359e+06 0.068124 0.043964 \n", + "1 4.686359e+06 0.067158 0.042242 \n", + "2 4.686358e+06 0.054104 0.032287 \n", + "3 4.686358e+06 0.052650 0.035780 \n", + "4 4.686358e+06 0.045152 0.032856 " ] }, - "execution_count": 10, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } @@ -994,9 +1182,17 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 33, "id": "1a7a7dd3", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-12-18T18:15:04.468046Z", + "iopub.status.busy": "2024-12-18T18:15:04.467527Z", + "iopub.status.idle": "2024-12-18T18:15:04.550758Z", + "shell.execute_reply": "2024-12-18T18:15:04.549913Z", + "shell.execute_reply.started": "2024-12-18T18:15:04.468010Z" + } + }, "outputs": [], "source": [ "# check if everything looks good\n", @@ -1011,9 +1207,17 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 34, "id": "2e284de5", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-12-18T18:15:20.286032Z", + "iopub.status.busy": "2024-12-18T18:15:20.285490Z", + "iopub.status.idle": "2024-12-18T18:15:20.295342Z", + "shell.execute_reply": "2024-12-18T18:15:20.293643Z", + "shell.execute_reply.started": "2024-12-18T18:15:20.285995Z" + } + }, "outputs": [], "source": [ "gdf.crs = dataset.crs # set geodataframe CRS" @@ -1021,16 +1225,28 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 35, "id": "27f9b8b3", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-12-18T18:15:23.807901Z", + "iopub.status.busy": "2024-12-18T18:15:23.807396Z", + "iopub.status.idle": "2024-12-18T18:15:27.257072Z", + "shell.execute_reply": "2024-12-18T18:15:27.256662Z", + "shell.execute_reply.started": "2024-12-18T18:15:23.807866Z" + } + }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "/var/folders/5h/h0hb76hj7h90xczzdv1425fr0000gp/T/ipykernel_73938/571464815.py:1: UserWarning: Column names longer than 10 characters will be truncated when saved to ESRI Shapefile.\n", - " gdf.to_file(\"/Users/zoltan/Dropbox/Segmentation/Kalinda_Roberts_project/projected_grains.shp\") # write shapefile\n" + "/var/folders/wn/31h1q45j6y321jzk91br_d3m0000gn/T/ipykernel_7410/571464815.py:1: UserWarning: Column names longer than 10 characters will be truncated when saved to ESRI Shapefile.\n", + " gdf.to_file(\"/Users/zoltan/Dropbox/Segmentation/Kalinda_Roberts_project/projected_grains.shp\") # write shapefile\n", + "/Users/zoltan/miniforge3/envs/segmenteverygrain/lib/python3.9/site-packages/pyogrio/raw.py:723: RuntimeWarning: Normalized/laundered field name: 'major_axis_length' to 'major_axis'\n", + " ogr_write(\n", + "/Users/zoltan/miniforge3/envs/segmenteverygrain/lib/python3.9/site-packages/pyogrio/raw.py:723: RuntimeWarning: Normalized/laundered field name: 'minor_axis_length' to 'minor_axis'\n", + " ogr_write(\n" ] } ], @@ -1040,9 +1256,17 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 36, "id": "361ceb2d", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-12-18T18:15:34.148648Z", + "iopub.status.busy": "2024-12-18T18:15:34.147740Z", + "iopub.status.idle": "2024-12-18T18:15:34.153332Z", + "shell.execute_reply": "2024-12-18T18:15:34.152650Z", + "shell.execute_reply.started": "2024-12-18T18:15:34.148611Z" + } + }, "outputs": [], "source": [ "dataset.close()" @@ -1065,7 +1289,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.20" + "version": "3.9.20" } }, "nbformat": 4,