From c0814bbd6b1afc2b3f34979c2fc2dadc3397e87b Mon Sep 17 00:00:00 2001 From: Qiusheng Wu Date: Mon, 7 Oct 2024 15:30:11 -0500 Subject: [PATCH 1/4] Add zonal stats to region groups --- samgeo/common.py | 49 +++++++++++++++++++++++++++++++++++++++++++++-- samgeo/samgeo2.py | 4 ++++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/samgeo/common.py b/samgeo/common.py index b145c069..d316a360 100644 --- a/samgeo/common.py +++ b/samgeo/common.py @@ -3529,6 +3529,7 @@ def region_groups( max_size: Optional[int] = None, threshold: Optional[int] = None, properties: Optional[List[str]] = None, + intensity_image: Optional[Union[str, "xr.DataArray", np.ndarray]] = None, out_csv: Optional[str] = None, out_vector: Optional[str] = None, out_image: Optional[str] = None, @@ -3550,6 +3551,8 @@ def region_groups( properties (Optional[List[str]], optional): List of properties to measure. See https://scikit-image.org/docs/stable/api/skimage.measure.html#skimage.measure.regionprops Defaults to None. + intensity_image (Optional[Union[str, xr.DataArray, np.ndarray]], optional): + Intensity image to measure properties. Defaults to None. out_csv (Optional[str], optional): Path to save the properties as a CSV file. Defaults to None. out_vector (Optional[str], optional): Path to save the vector file. @@ -3583,6 +3586,17 @@ def region_groups( if threshold is None: threshold = min_size + # Define a custom function to calculate median intensity + def intensity_median(region, intensity_image): + # Extract the intensity values for the region + return np.median(intensity_image[region]) + + # Add your custom function to the list of extra properties + if intensity_image is not None: + extra_props = (intensity_median,) + else: + extra_props = None + if properties is None: properties = [ "label", @@ -3600,8 +3614,33 @@ def region_groups( "solidity", ] + if intensity_image is not None: + + properties += [ + "intensity_max", + "intensity_mean", + "intensity_min", + "intensity_std", + ] + + if intensity_image is not None: + if isinstance(intensity_image, str): + ds = rxr.open_rasterio(intensity_image) + intensity_da = ds.sel(band=1) + intensity_image = intensity_da.values.squeeze() + elif isinstance(intensity_image, xr.DataArray): + intensity_image = intensity_image.values.squeeze() + elif isinstance(intensity_image, np.ndarray): + pass + else: + raise ValueError( + "The intensity_image must be a file path, xarray DataArray, or numpy array." + ) + label_image = measure.label(array, connectivity=connectivity) - props = measure.regionprops_table(label_image, properties=properties) + props = measure.regionprops_table( + label_image, properties=properties, intensity_image=intensity_image, **kwargs + ) df = pd.DataFrame(props) @@ -3654,7 +3693,13 @@ def region_groups( label_image, num_labels = measure.label( label_image, connectivity=connectivity, return_num=True ) - props = measure.regionprops_table(label_image, properties=properties) + props = measure.regionprops_table( + label_image, + properties=properties, + intensity_image=intensity_image, + extra_properties=extra_props, + **kwargs, + ) df = pd.DataFrame(props) df["elongation"] = df["axis_major_length"] / df["axis_minor_length"] diff --git a/samgeo/samgeo2.py b/samgeo/samgeo2.py index f0e7555a..0860fb17 100644 --- a/samgeo/samgeo2.py +++ b/samgeo/samgeo2.py @@ -1523,6 +1523,7 @@ def region_groups( max_size: Optional[int] = None, threshold: Optional[int] = None, properties: Optional[List[str]] = None, + intensity_image: Optional[Union[str, "xr.DataArray", np.ndarray]] = None, out_csv: Optional[str] = None, out_vector: Optional[str] = None, out_image: Optional[str] = None, @@ -1546,6 +1547,8 @@ def region_groups( properties (Optional[List[str]], optional): List of properties to measure. See https://scikit-image.org/docs/stable/api/skimage.measure.html#skimage.measure.regionprops Defaults to None. + intensity_image (Optional[Union[str, xr.DataArray, np.ndarray]], optional): + Intensity image to use for properties. Defaults to None. out_csv (Optional[str], optional): Path to save the properties as a CSV file. Defaults to None. out_vector (Optional[str], optional): Path to save the vector file. @@ -1563,6 +1566,7 @@ def region_groups( max_size=max_size, threshold=threshold, properties=properties, + intensity_image=intensity_image, out_csv=out_csv, out_vector=out_vector, out_image=out_image, From ae966ced38ace9021f2512547baea8a51fec9aea Mon Sep 17 00:00:00 2001 From: Qiusheng Wu Date: Mon, 7 Oct 2024 17:37:22 -0500 Subject: [PATCH 2/4] Update IPPN notebook --- docs/workshops/IPPN_2024.ipynb | 263 +++++++++++++++++++++++++-------- 1 file changed, 199 insertions(+), 64 deletions(-) diff --git a/docs/workshops/IPPN_2024.ipynb b/docs/workshops/IPPN_2024.ipynb index c0dda3cf..47143860 100644 --- a/docs/workshops/IPPN_2024.ipynb +++ b/docs/workshops/IPPN_2024.ipynb @@ -637,6 +637,62 @@ { "cell_type": "markdown", "id": "50", + "metadata": {}, + "source": [ + "### Visualize CHM\n", + "\n", + "Similarly, you can visualize the Canopy Height Model (CHM) from D2S using the code below." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "51", + "metadata": {}, + "outputs": [], + "source": [ + "# Example of creating new collection of data products with the \"chm\" data type\n", + "chm_data_products = data_products.filter_by_data_type(\"chm\")\n", + "print(chm_data_products)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "52", + "metadata": {}, + "outputs": [], + "source": [ + "chm_data = chm_data_products[0]\n", + "chm_url_202206 = chm_data.url\n", + "chm_url_202206 = leafmap.d2s_tile(chm_url_202206)\n", + "m.add_cog_layer(chm_url_202206, colormap_name=\"jet\", name=\"CHM 202206\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "53", + "metadata": {}, + "outputs": [], + "source": [ + "leafmap.cog_stats(chm_url_202206)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "54", + "metadata": {}, + "outputs": [], + "source": [ + "m.add_colormap(cmap=\"jet\", vmin=0, vmax=13, label=\"Elevation (m)\")\n", + "m" + ] + }, + { + "cell_type": "markdown", + "id": "55", "metadata": { "id": "37" }, @@ -647,7 +703,7 @@ { "cell_type": "code", "execution_count": null, - "id": "51", + "id": "56", "metadata": {}, "outputs": [], "source": [ @@ -656,7 +712,7 @@ }, { "cell_type": "markdown", - "id": "52", + "id": "57", "metadata": {}, "source": [ "Add tree boundaries to the map." @@ -665,7 +721,7 @@ { "cell_type": "code", "execution_count": null, - "id": "53", + "id": "58", "metadata": {}, "outputs": [], "source": [ @@ -676,7 +732,7 @@ { "cell_type": "code", "execution_count": null, - "id": "54", + "id": "59", "metadata": {}, "outputs": [], "source": [ @@ -685,7 +741,7 @@ }, { "cell_type": "markdown", - "id": "55", + "id": "60", "metadata": {}, "source": [ "### Get another flight\n", @@ -696,7 +752,7 @@ { "cell_type": "code", "execution_count": null, - "id": "56", + "id": "61", "metadata": {}, "outputs": [], "source": [ @@ -710,7 +766,7 @@ { "cell_type": "code", "execution_count": null, - "id": "57", + "id": "62", "metadata": {}, "outputs": [], "source": [ @@ -724,7 +780,7 @@ }, { "cell_type": "markdown", - "id": "58", + "id": "63", "metadata": {}, "source": [ "### Compare two ortho images\n", @@ -735,7 +791,7 @@ { "cell_type": "code", "execution_count": null, - "id": "59", + "id": "64", "metadata": {}, "outputs": [], "source": [ @@ -755,7 +811,7 @@ }, { "cell_type": "markdown", - "id": "60", + "id": "65", "metadata": {}, "source": [ "## Download data from D2S\n", @@ -766,7 +822,7 @@ { "cell_type": "code", "execution_count": null, - "id": "61", + "id": "66", "metadata": {}, "outputs": [], "source": [ @@ -776,7 +832,7 @@ { "cell_type": "code", "execution_count": null, - "id": "62", + "id": "67", "metadata": {}, "outputs": [], "source": [ @@ -787,7 +843,7 @@ { "cell_type": "code", "execution_count": null, - "id": "63", + "id": "68", "metadata": {}, "outputs": [], "source": [ @@ -798,7 +854,7 @@ }, { "cell_type": "markdown", - "id": "64", + "id": "69", "metadata": {}, "source": [ "Draw an area of interest (AOI) on the map. If an AOI is not provided, a default AOI will be used." @@ -807,7 +863,7 @@ { "cell_type": "code", "execution_count": null, - "id": "65", + "id": "70", "metadata": {}, "outputs": [], "source": [ @@ -820,7 +876,7 @@ { "cell_type": "code", "execution_count": null, - "id": "66", + "id": "71", "metadata": {}, "outputs": [], "source": [ @@ -832,7 +888,7 @@ { "cell_type": "code", "execution_count": null, - "id": "67", + "id": "72", "metadata": {}, "outputs": [], "source": [ @@ -843,7 +899,7 @@ { "cell_type": "code", "execution_count": null, - "id": "68", + "id": "73", "metadata": {}, "outputs": [], "source": [ @@ -853,7 +909,7 @@ }, { "cell_type": "markdown", - "id": "69", + "id": "74", "metadata": {}, "source": [ "Resample the ortho imagery from 1 cm to 10 cm resolution." @@ -862,7 +918,7 @@ { "cell_type": "code", "execution_count": null, - "id": "70", + "id": "75", "metadata": {}, "outputs": [], "source": [ @@ -872,7 +928,7 @@ }, { "cell_type": "markdown", - "id": "71", + "id": "76", "metadata": {}, "source": [ "Clip the ortho image to the AOI." @@ -881,7 +937,7 @@ { "cell_type": "code", "execution_count": null, - "id": "72", + "id": "77", "metadata": {}, "outputs": [], "source": [ @@ -891,7 +947,7 @@ }, { "cell_type": "markdown", - "id": "73", + "id": "78", "metadata": {}, "source": [ "Save the clipped ortho image to a GeoTIFF file." @@ -900,7 +956,7 @@ { "cell_type": "code", "execution_count": null, - "id": "74", + "id": "79", "metadata": {}, "outputs": [], "source": [ @@ -910,7 +966,59 @@ }, { "cell_type": "markdown", - "id": "75", + "id": "80", + "metadata": {}, + "source": [ + "Read the CHM dataset from D2S as a DataArray." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "81", + "metadata": {}, + "outputs": [], + "source": [ + "chm_data = rxr.open_rasterio(chm_url_202206)\n", + "chm_data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "82", + "metadata": {}, + "outputs": [], + "source": [ + "resampled_chm_data = chm_data.rio.reproject(crs, resolution=(0.1, 0.1))\n", + "resampled_chm_data.shape" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "83", + "metadata": {}, + "outputs": [], + "source": [ + "clipped_chm_data = resampled_chm_data.rio.clip(gdf.geometry, gdf.crs)\n", + "clipped_chm_data.shape" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "84", + "metadata": {}, + "outputs": [], + "source": [ + "chm_image = \"chm_202206.tif\"\n", + "clipped_chm_data.sel(band=[1]).rio.to_raster(chm_image)" + ] + }, + { + "cell_type": "markdown", + "id": "85", "metadata": {}, "source": [ "Visualize the clipped ortho image." @@ -919,7 +1027,7 @@ { "cell_type": "code", "execution_count": null, - "id": "76", + "id": "86", "metadata": {}, "outputs": [], "source": [ @@ -931,7 +1039,7 @@ }, { "cell_type": "markdown", - "id": "77", + "id": "87", "metadata": {}, "source": [ "## Segmenting Drone Imagery using Samgeo\n", @@ -942,7 +1050,7 @@ { "cell_type": "code", "execution_count": null, - "id": "78", + "id": "88", "metadata": {}, "outputs": [], "source": [ @@ -952,7 +1060,7 @@ { "cell_type": "code", "execution_count": null, - "id": "79", + "id": "89", "metadata": {}, "outputs": [], "source": [ @@ -961,7 +1069,7 @@ }, { "cell_type": "markdown", - "id": "80", + "id": "90", "metadata": {}, "source": [ "### Automatic mask generation" @@ -970,7 +1078,7 @@ { "cell_type": "code", "execution_count": null, - "id": "81", + "id": "91", "metadata": {}, "outputs": [], "source": [ @@ -980,7 +1088,7 @@ { "cell_type": "code", "execution_count": null, - "id": "82", + "id": "92", "metadata": {}, "outputs": [], "source": [ @@ -990,7 +1098,7 @@ { "cell_type": "code", "execution_count": null, - "id": "83", + "id": "93", "metadata": {}, "outputs": [], "source": [ @@ -999,7 +1107,7 @@ }, { "cell_type": "markdown", - "id": "84", + "id": "94", "metadata": {}, "source": [ "![image](https://github.com/user-attachments/assets/fec9ad33-338e-4d1f-95e5-5f7b58e15edb)" @@ -1008,7 +1116,7 @@ { "cell_type": "code", "execution_count": null, - "id": "85", + "id": "95", "metadata": {}, "outputs": [], "source": [ @@ -1017,7 +1125,7 @@ }, { "cell_type": "markdown", - "id": "86", + "id": "96", "metadata": {}, "source": [ "![image](https://github.com/user-attachments/assets/32036cec-96a2-46c7-b948-a859925d8600)" @@ -1025,7 +1133,7 @@ }, { "cell_type": "markdown", - "id": "87", + "id": "97", "metadata": {}, "source": [ "Show the object annotations (objects with random color) on the map." @@ -1034,7 +1142,7 @@ { "cell_type": "code", "execution_count": null, - "id": "88", + "id": "98", "metadata": {}, "outputs": [], "source": [ @@ -1043,7 +1151,7 @@ }, { "cell_type": "markdown", - "id": "89", + "id": "99", "metadata": {}, "source": [ "![image](https://github.com/user-attachments/assets/8a05f797-5a08-4bb2-b6b3-ee8f82d8bd32)" @@ -1051,7 +1159,7 @@ }, { "cell_type": "markdown", - "id": "90", + "id": "100", "metadata": {}, "source": [ "Compare images with a slider." @@ -1060,7 +1168,7 @@ { "cell_type": "code", "execution_count": null, - "id": "91", + "id": "101", "metadata": {}, "outputs": [], "source": [ @@ -1074,7 +1182,7 @@ }, { "cell_type": "markdown", - "id": "92", + "id": "102", "metadata": {}, "source": [ "Add segmentation result to the map." @@ -1083,7 +1191,7 @@ { "cell_type": "code", "execution_count": null, - "id": "93", + "id": "103", "metadata": {}, "outputs": [], "source": [ @@ -1093,7 +1201,7 @@ }, { "cell_type": "markdown", - "id": "94", + "id": "104", "metadata": {}, "source": [ "Convert the object masks to vector format, such as GeoPackage, Shapefile, or GeoJSON." @@ -1102,7 +1210,7 @@ { "cell_type": "code", "execution_count": null, - "id": "95", + "id": "105", "metadata": {}, "outputs": [], "source": [ @@ -1112,7 +1220,7 @@ { "cell_type": "code", "execution_count": null, - "id": "96", + "id": "106", "metadata": {}, "outputs": [], "source": [ @@ -1121,7 +1229,7 @@ }, { "cell_type": "markdown", - "id": "97", + "id": "107", "metadata": {}, "source": [ "### Automatic mask generation options\n", @@ -1132,7 +1240,7 @@ { "cell_type": "code", "execution_count": null, - "id": "98", + "id": "108", "metadata": {}, "outputs": [], "source": [ @@ -1155,7 +1263,7 @@ { "cell_type": "code", "execution_count": null, - "id": "99", + "id": "109", "metadata": {}, "outputs": [], "source": [ @@ -1165,7 +1273,7 @@ { "cell_type": "code", "execution_count": null, - "id": "100", + "id": "110", "metadata": {}, "outputs": [], "source": [ @@ -1174,7 +1282,7 @@ }, { "cell_type": "markdown", - "id": "101", + "id": "111", "metadata": {}, "source": [ "![image](https://github.com/user-attachments/assets/ff07bff9-f0d1-41c6-a641-ce9f4734fd61)" @@ -1183,7 +1291,7 @@ { "cell_type": "code", "execution_count": null, - "id": "102", + "id": "112", "metadata": {}, "outputs": [], "source": [ @@ -1192,7 +1300,7 @@ }, { "cell_type": "markdown", - "id": "103", + "id": "113", "metadata": {}, "source": [ "![image](https://github.com/user-attachments/assets/1e1df62c-ec44-4c5e-aa5a-4025d078ff6b)" @@ -1201,7 +1309,7 @@ { "cell_type": "code", "execution_count": null, - "id": "104", + "id": "114", "metadata": {}, "outputs": [], "source": [ @@ -1215,7 +1323,34 @@ }, { "cell_type": "markdown", - "id": "105", + "id": "115", + "metadata": {}, + "source": [ + "Remove small objects." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "116", + "metadata": {}, + "outputs": [], + "source": [ + "sam2.region_groups(\n", + " image,\n", + " connectivity=1,\n", + " min_size=10,\n", + " max_size=1000,\n", + " intensity_image=\"chm_202206.tif\",\n", + " out_image=\"objects.tif\",\n", + " out_csv=\"objects.csv\",\n", + " out_vector=\"objects.gpkg\",\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "117", "metadata": {}, "source": [ "### Using box prompts" @@ -1224,7 +1359,7 @@ { "cell_type": "code", "execution_count": null, - "id": "106", + "id": "118", "metadata": {}, "outputs": [], "source": [ @@ -1235,7 +1370,7 @@ { "cell_type": "code", "execution_count": null, - "id": "107", + "id": "119", "metadata": {}, "outputs": [], "source": [ @@ -1246,7 +1381,7 @@ { "cell_type": "code", "execution_count": null, - "id": "108", + "id": "120", "metadata": {}, "outputs": [], "source": [ @@ -1265,7 +1400,7 @@ { "cell_type": "code", "execution_count": null, - "id": "109", + "id": "121", "metadata": {}, "outputs": [], "source": [ @@ -1279,7 +1414,7 @@ { "cell_type": "code", "execution_count": null, - "id": "110", + "id": "122", "metadata": {}, "outputs": [], "source": [ @@ -1289,7 +1424,7 @@ { "cell_type": "code", "execution_count": null, - "id": "111", + "id": "123", "metadata": {}, "outputs": [], "source": [ @@ -1301,7 +1436,7 @@ { "cell_type": "code", "execution_count": null, - "id": "112", + "id": "124", "metadata": {}, "outputs": [], "source": [ @@ -1313,7 +1448,7 @@ }, { "cell_type": "markdown", - "id": "113", + "id": "125", "metadata": {}, "source": [ "![image](https://github.com/user-attachments/assets/0a9b794d-cf94-4e5c-9134-8799e67d338c)" @@ -1339,7 +1474,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.8" + "version": "3.12.7" } }, "nbformat": 4, From 2ab500a34879c2920c9601386bfb965e1855d30e Mon Sep 17 00:00:00 2001 From: Qiusheng Wu Date: Mon, 7 Oct 2024 17:38:14 -0500 Subject: [PATCH 3/4] Pin numpy version --- docs/workshops/IPPN_2024.ipynb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/workshops/IPPN_2024.ipynb b/docs/workshops/IPPN_2024.ipynb index 47143860..b35d6aa1 100644 --- a/docs/workshops/IPPN_2024.ipynb +++ b/docs/workshops/IPPN_2024.ipynb @@ -70,6 +70,16 @@ "# %pip install -U \"leafmap[raster]\" segment-geospatial d2spy" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "c24c3abd", + "metadata": {}, + "outputs": [], + "source": [ + "# %pip install numpy==1.26.4" + ] + }, { "cell_type": "markdown", "id": "2", From c99db08b28e3a8aa3fad6a8f718890e14f715d8b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 22:38:27 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/workshops/IPPN_2024.ipynb | 250 ++++++++++++++++----------------- 1 file changed, 125 insertions(+), 125 deletions(-) diff --git a/docs/workshops/IPPN_2024.ipynb b/docs/workshops/IPPN_2024.ipynb index b35d6aa1..91860ad4 100644 --- a/docs/workshops/IPPN_2024.ipynb +++ b/docs/workshops/IPPN_2024.ipynb @@ -73,7 +73,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c24c3abd", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -82,7 +82,7 @@ }, { "cell_type": "markdown", - "id": "2", + "id": "3", "metadata": { "id": "3" }, @@ -95,7 +95,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3", + "id": "4", "metadata": { "id": "4" }, @@ -106,7 +106,7 @@ }, { "cell_type": "markdown", - "id": "4", + "id": "5", "metadata": { "id": "9" }, @@ -119,7 +119,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "6", "metadata": {}, "outputs": [], "source": [ @@ -128,7 +128,7 @@ }, { "cell_type": "markdown", - "id": "6", + "id": "7", "metadata": { "id": "11" }, @@ -139,7 +139,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -148,7 +148,7 @@ }, { "cell_type": "markdown", - "id": "8", + "id": "9", "metadata": { "id": "13" }, @@ -159,7 +159,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9", + "id": "10", "metadata": {}, "outputs": [], "source": [ @@ -169,7 +169,7 @@ }, { "cell_type": "markdown", - "id": "10", + "id": "11", "metadata": { "id": "17" }, @@ -184,7 +184,7 @@ { "cell_type": "code", "execution_count": null, - "id": "11", + "id": "12", "metadata": {}, "outputs": [], "source": [ @@ -194,7 +194,7 @@ }, { "cell_type": "markdown", - "id": "12", + "id": "13", "metadata": { "id": "19" }, @@ -205,7 +205,7 @@ { "cell_type": "code", "execution_count": null, - "id": "13", + "id": "14", "metadata": { "id": "20", "outputId": "b1fea60d-6a8c-4c9e-fc13-0e3525c4a917" @@ -217,7 +217,7 @@ }, { "cell_type": "markdown", - "id": "14", + "id": "15", "metadata": { "id": "21" }, @@ -228,7 +228,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15", + "id": "16", "metadata": { "id": "22", "outputId": "c4f2108b-8a2b-4903-db1a-bcc0690a3651" @@ -241,7 +241,7 @@ }, { "cell_type": "markdown", - "id": "16", + "id": "17", "metadata": { "id": "23" }, @@ -252,7 +252,7 @@ { "cell_type": "code", "execution_count": null, - "id": "17", + "id": "18", "metadata": {}, "outputs": [], "source": [ @@ -263,7 +263,7 @@ }, { "cell_type": "markdown", - "id": "18", + "id": "19", "metadata": { "id": "25" }, @@ -275,7 +275,7 @@ }, { "cell_type": "markdown", - "id": "19", + "id": "20", "metadata": { "id": "de1a9ee4-d27e-49cb-9dcf-db32aab48ccc" }, @@ -287,7 +287,7 @@ { "cell_type": "code", "execution_count": null, - "id": "20", + "id": "21", "metadata": {}, "outputs": [], "source": [ @@ -303,7 +303,7 @@ { "cell_type": "code", "execution_count": null, - "id": "21", + "id": "22", "metadata": {}, "outputs": [], "source": [ @@ -318,7 +318,7 @@ { "cell_type": "code", "execution_count": null, - "id": "22", + "id": "23", "metadata": {}, "outputs": [], "source": [ @@ -331,7 +331,7 @@ }, { "cell_type": "markdown", - "id": "23", + "id": "24", "metadata": { "id": "TOx4ytjZKLOC" }, @@ -344,7 +344,7 @@ { "cell_type": "code", "execution_count": null, - "id": "24", + "id": "25", "metadata": {}, "outputs": [], "source": [ @@ -356,7 +356,7 @@ }, { "cell_type": "markdown", - "id": "25", + "id": "26", "metadata": { "id": "zTQJkyxaKxKn" }, @@ -367,7 +367,7 @@ { "cell_type": "code", "execution_count": null, - "id": "26", + "id": "27", "metadata": {}, "outputs": [], "source": [ @@ -378,7 +378,7 @@ }, { "cell_type": "markdown", - "id": "27", + "id": "28", "metadata": { "id": "O6fdeffmLIN5" }, @@ -389,7 +389,7 @@ { "cell_type": "code", "execution_count": null, - "id": "28", + "id": "29", "metadata": {}, "outputs": [], "source": [ @@ -398,7 +398,7 @@ }, { "cell_type": "markdown", - "id": "29", + "id": "30", "metadata": {}, "source": [ "### Get the project boundary" @@ -406,7 +406,7 @@ }, { "cell_type": "markdown", - "id": "30", + "id": "31", "metadata": { "id": "yqo000pqLYn4" }, @@ -417,7 +417,7 @@ { "cell_type": "code", "execution_count": null, - "id": "31", + "id": "32", "metadata": {}, "outputs": [], "source": [ @@ -428,7 +428,7 @@ }, { "cell_type": "markdown", - "id": "32", + "id": "33", "metadata": { "id": "OvFhMBNtLv9X" }, @@ -441,7 +441,7 @@ { "cell_type": "code", "execution_count": null, - "id": "33", + "id": "34", "metadata": {}, "outputs": [], "source": [ @@ -454,7 +454,7 @@ }, { "cell_type": "markdown", - "id": "34", + "id": "35", "metadata": { "id": "eT8rrteTMM4z" }, @@ -467,7 +467,7 @@ { "cell_type": "code", "execution_count": null, - "id": "35", + "id": "36", "metadata": {}, "outputs": [], "source": [ @@ -481,7 +481,7 @@ }, { "cell_type": "markdown", - "id": "36", + "id": "37", "metadata": { "id": "dOlbqBhRNX4e" }, @@ -492,7 +492,7 @@ { "cell_type": "code", "execution_count": null, - "id": "37", + "id": "38", "metadata": {}, "outputs": [], "source": [ @@ -502,7 +502,7 @@ }, { "cell_type": "markdown", - "id": "38", + "id": "39", "metadata": { "id": "ngIYB3tANljF" }, @@ -515,7 +515,7 @@ { "cell_type": "code", "execution_count": null, - "id": "39", + "id": "40", "metadata": {}, "outputs": [], "source": [ @@ -528,7 +528,7 @@ }, { "cell_type": "markdown", - "id": "40", + "id": "41", "metadata": { "id": "yiKBMsv7N4cy" }, @@ -539,7 +539,7 @@ { "cell_type": "code", "execution_count": null, - "id": "41", + "id": "42", "metadata": {}, "outputs": [], "source": [ @@ -550,7 +550,7 @@ }, { "cell_type": "markdown", - "id": "42", + "id": "43", "metadata": { "id": "ZryOKEuROOnu" }, @@ -563,7 +563,7 @@ { "cell_type": "code", "execution_count": null, - "id": "43", + "id": "44", "metadata": {}, "outputs": [], "source": [ @@ -578,7 +578,7 @@ }, { "cell_type": "markdown", - "id": "44", + "id": "45", "metadata": { "id": "33" }, @@ -591,7 +591,7 @@ { "cell_type": "code", "execution_count": null, - "id": "45", + "id": "46", "metadata": {}, "outputs": [], "source": [ @@ -603,7 +603,7 @@ { "cell_type": "code", "execution_count": null, - "id": "46", + "id": "47", "metadata": {}, "outputs": [], "source": [ @@ -616,7 +616,7 @@ { "cell_type": "code", "execution_count": null, - "id": "47", + "id": "48", "metadata": {}, "outputs": [], "source": [ @@ -625,7 +625,7 @@ }, { "cell_type": "markdown", - "id": "48", + "id": "49", "metadata": { "id": "35" }, @@ -636,7 +636,7 @@ { "cell_type": "code", "execution_count": null, - "id": "49", + "id": "50", "metadata": {}, "outputs": [], "source": [ @@ -646,7 +646,7 @@ }, { "cell_type": "markdown", - "id": "50", + "id": "51", "metadata": {}, "source": [ "### Visualize CHM\n", @@ -657,7 +657,7 @@ { "cell_type": "code", "execution_count": null, - "id": "51", + "id": "52", "metadata": {}, "outputs": [], "source": [ @@ -669,7 +669,7 @@ { "cell_type": "code", "execution_count": null, - "id": "52", + "id": "53", "metadata": {}, "outputs": [], "source": [ @@ -682,7 +682,7 @@ { "cell_type": "code", "execution_count": null, - "id": "53", + "id": "54", "metadata": {}, "outputs": [], "source": [ @@ -692,7 +692,7 @@ { "cell_type": "code", "execution_count": null, - "id": "54", + "id": "55", "metadata": {}, "outputs": [], "source": [ @@ -702,7 +702,7 @@ }, { "cell_type": "markdown", - "id": "55", + "id": "56", "metadata": { "id": "37" }, @@ -713,7 +713,7 @@ { "cell_type": "code", "execution_count": null, - "id": "56", + "id": "57", "metadata": {}, "outputs": [], "source": [ @@ -722,7 +722,7 @@ }, { "cell_type": "markdown", - "id": "57", + "id": "58", "metadata": {}, "source": [ "Add tree boundaries to the map." @@ -731,7 +731,7 @@ { "cell_type": "code", "execution_count": null, - "id": "58", + "id": "59", "metadata": {}, "outputs": [], "source": [ @@ -742,7 +742,7 @@ { "cell_type": "code", "execution_count": null, - "id": "59", + "id": "60", "metadata": {}, "outputs": [], "source": [ @@ -751,7 +751,7 @@ }, { "cell_type": "markdown", - "id": "60", + "id": "61", "metadata": {}, "source": [ "### Get another flight\n", @@ -762,7 +762,7 @@ { "cell_type": "code", "execution_count": null, - "id": "61", + "id": "62", "metadata": {}, "outputs": [], "source": [ @@ -776,7 +776,7 @@ { "cell_type": "code", "execution_count": null, - "id": "62", + "id": "63", "metadata": {}, "outputs": [], "source": [ @@ -790,7 +790,7 @@ }, { "cell_type": "markdown", - "id": "63", + "id": "64", "metadata": {}, "source": [ "### Compare two ortho images\n", @@ -801,7 +801,7 @@ { "cell_type": "code", "execution_count": null, - "id": "64", + "id": "65", "metadata": {}, "outputs": [], "source": [ @@ -821,7 +821,7 @@ }, { "cell_type": "markdown", - "id": "65", + "id": "66", "metadata": {}, "source": [ "## Download data from D2S\n", @@ -832,7 +832,7 @@ { "cell_type": "code", "execution_count": null, - "id": "66", + "id": "67", "metadata": {}, "outputs": [], "source": [ @@ -842,7 +842,7 @@ { "cell_type": "code", "execution_count": null, - "id": "67", + "id": "68", "metadata": {}, "outputs": [], "source": [ @@ -853,7 +853,7 @@ { "cell_type": "code", "execution_count": null, - "id": "68", + "id": "69", "metadata": {}, "outputs": [], "source": [ @@ -864,7 +864,7 @@ }, { "cell_type": "markdown", - "id": "69", + "id": "70", "metadata": {}, "source": [ "Draw an area of interest (AOI) on the map. If an AOI is not provided, a default AOI will be used." @@ -873,7 +873,7 @@ { "cell_type": "code", "execution_count": null, - "id": "70", + "id": "71", "metadata": {}, "outputs": [], "source": [ @@ -886,7 +886,7 @@ { "cell_type": "code", "execution_count": null, - "id": "71", + "id": "72", "metadata": {}, "outputs": [], "source": [ @@ -898,7 +898,7 @@ { "cell_type": "code", "execution_count": null, - "id": "72", + "id": "73", "metadata": {}, "outputs": [], "source": [ @@ -909,7 +909,7 @@ { "cell_type": "code", "execution_count": null, - "id": "73", + "id": "74", "metadata": {}, "outputs": [], "source": [ @@ -919,7 +919,7 @@ }, { "cell_type": "markdown", - "id": "74", + "id": "75", "metadata": {}, "source": [ "Resample the ortho imagery from 1 cm to 10 cm resolution." @@ -928,7 +928,7 @@ { "cell_type": "code", "execution_count": null, - "id": "75", + "id": "76", "metadata": {}, "outputs": [], "source": [ @@ -938,7 +938,7 @@ }, { "cell_type": "markdown", - "id": "76", + "id": "77", "metadata": {}, "source": [ "Clip the ortho image to the AOI." @@ -947,7 +947,7 @@ { "cell_type": "code", "execution_count": null, - "id": "77", + "id": "78", "metadata": {}, "outputs": [], "source": [ @@ -957,7 +957,7 @@ }, { "cell_type": "markdown", - "id": "78", + "id": "79", "metadata": {}, "source": [ "Save the clipped ortho image to a GeoTIFF file." @@ -966,7 +966,7 @@ { "cell_type": "code", "execution_count": null, - "id": "79", + "id": "80", "metadata": {}, "outputs": [], "source": [ @@ -976,7 +976,7 @@ }, { "cell_type": "markdown", - "id": "80", + "id": "81", "metadata": {}, "source": [ "Read the CHM dataset from D2S as a DataArray." @@ -985,7 +985,7 @@ { "cell_type": "code", "execution_count": null, - "id": "81", + "id": "82", "metadata": {}, "outputs": [], "source": [ @@ -996,7 +996,7 @@ { "cell_type": "code", "execution_count": null, - "id": "82", + "id": "83", "metadata": {}, "outputs": [], "source": [ @@ -1007,7 +1007,7 @@ { "cell_type": "code", "execution_count": null, - "id": "83", + "id": "84", "metadata": {}, "outputs": [], "source": [ @@ -1018,7 +1018,7 @@ { "cell_type": "code", "execution_count": null, - "id": "84", + "id": "85", "metadata": {}, "outputs": [], "source": [ @@ -1028,7 +1028,7 @@ }, { "cell_type": "markdown", - "id": "85", + "id": "86", "metadata": {}, "source": [ "Visualize the clipped ortho image." @@ -1037,7 +1037,7 @@ { "cell_type": "code", "execution_count": null, - "id": "86", + "id": "87", "metadata": {}, "outputs": [], "source": [ @@ -1049,7 +1049,7 @@ }, { "cell_type": "markdown", - "id": "87", + "id": "88", "metadata": {}, "source": [ "## Segmenting Drone Imagery using Samgeo\n", @@ -1060,7 +1060,7 @@ { "cell_type": "code", "execution_count": null, - "id": "88", + "id": "89", "metadata": {}, "outputs": [], "source": [ @@ -1070,7 +1070,7 @@ { "cell_type": "code", "execution_count": null, - "id": "89", + "id": "90", "metadata": {}, "outputs": [], "source": [ @@ -1079,7 +1079,7 @@ }, { "cell_type": "markdown", - "id": "90", + "id": "91", "metadata": {}, "source": [ "### Automatic mask generation" @@ -1088,7 +1088,7 @@ { "cell_type": "code", "execution_count": null, - "id": "91", + "id": "92", "metadata": {}, "outputs": [], "source": [ @@ -1098,7 +1098,7 @@ { "cell_type": "code", "execution_count": null, - "id": "92", + "id": "93", "metadata": {}, "outputs": [], "source": [ @@ -1108,7 +1108,7 @@ { "cell_type": "code", "execution_count": null, - "id": "93", + "id": "94", "metadata": {}, "outputs": [], "source": [ @@ -1117,7 +1117,7 @@ }, { "cell_type": "markdown", - "id": "94", + "id": "95", "metadata": {}, "source": [ "![image](https://github.com/user-attachments/assets/fec9ad33-338e-4d1f-95e5-5f7b58e15edb)" @@ -1126,7 +1126,7 @@ { "cell_type": "code", "execution_count": null, - "id": "95", + "id": "96", "metadata": {}, "outputs": [], "source": [ @@ -1135,7 +1135,7 @@ }, { "cell_type": "markdown", - "id": "96", + "id": "97", "metadata": {}, "source": [ "![image](https://github.com/user-attachments/assets/32036cec-96a2-46c7-b948-a859925d8600)" @@ -1143,7 +1143,7 @@ }, { "cell_type": "markdown", - "id": "97", + "id": "98", "metadata": {}, "source": [ "Show the object annotations (objects with random color) on the map." @@ -1152,7 +1152,7 @@ { "cell_type": "code", "execution_count": null, - "id": "98", + "id": "99", "metadata": {}, "outputs": [], "source": [ @@ -1161,7 +1161,7 @@ }, { "cell_type": "markdown", - "id": "99", + "id": "100", "metadata": {}, "source": [ "![image](https://github.com/user-attachments/assets/8a05f797-5a08-4bb2-b6b3-ee8f82d8bd32)" @@ -1169,7 +1169,7 @@ }, { "cell_type": "markdown", - "id": "100", + "id": "101", "metadata": {}, "source": [ "Compare images with a slider." @@ -1178,7 +1178,7 @@ { "cell_type": "code", "execution_count": null, - "id": "101", + "id": "102", "metadata": {}, "outputs": [], "source": [ @@ -1192,7 +1192,7 @@ }, { "cell_type": "markdown", - "id": "102", + "id": "103", "metadata": {}, "source": [ "Add segmentation result to the map." @@ -1201,7 +1201,7 @@ { "cell_type": "code", "execution_count": null, - "id": "103", + "id": "104", "metadata": {}, "outputs": [], "source": [ @@ -1211,7 +1211,7 @@ }, { "cell_type": "markdown", - "id": "104", + "id": "105", "metadata": {}, "source": [ "Convert the object masks to vector format, such as GeoPackage, Shapefile, or GeoJSON." @@ -1220,7 +1220,7 @@ { "cell_type": "code", "execution_count": null, - "id": "105", + "id": "106", "metadata": {}, "outputs": [], "source": [ @@ -1230,7 +1230,7 @@ { "cell_type": "code", "execution_count": null, - "id": "106", + "id": "107", "metadata": {}, "outputs": [], "source": [ @@ -1239,7 +1239,7 @@ }, { "cell_type": "markdown", - "id": "107", + "id": "108", "metadata": {}, "source": [ "### Automatic mask generation options\n", @@ -1250,7 +1250,7 @@ { "cell_type": "code", "execution_count": null, - "id": "108", + "id": "109", "metadata": {}, "outputs": [], "source": [ @@ -1273,7 +1273,7 @@ { "cell_type": "code", "execution_count": null, - "id": "109", + "id": "110", "metadata": {}, "outputs": [], "source": [ @@ -1283,7 +1283,7 @@ { "cell_type": "code", "execution_count": null, - "id": "110", + "id": "111", "metadata": {}, "outputs": [], "source": [ @@ -1292,7 +1292,7 @@ }, { "cell_type": "markdown", - "id": "111", + "id": "112", "metadata": {}, "source": [ "![image](https://github.com/user-attachments/assets/ff07bff9-f0d1-41c6-a641-ce9f4734fd61)" @@ -1301,7 +1301,7 @@ { "cell_type": "code", "execution_count": null, - "id": "112", + "id": "113", "metadata": {}, "outputs": [], "source": [ @@ -1310,7 +1310,7 @@ }, { "cell_type": "markdown", - "id": "113", + "id": "114", "metadata": {}, "source": [ "![image](https://github.com/user-attachments/assets/1e1df62c-ec44-4c5e-aa5a-4025d078ff6b)" @@ -1319,7 +1319,7 @@ { "cell_type": "code", "execution_count": null, - "id": "114", + "id": "115", "metadata": {}, "outputs": [], "source": [ @@ -1333,7 +1333,7 @@ }, { "cell_type": "markdown", - "id": "115", + "id": "116", "metadata": {}, "source": [ "Remove small objects." @@ -1342,7 +1342,7 @@ { "cell_type": "code", "execution_count": null, - "id": "116", + "id": "117", "metadata": {}, "outputs": [], "source": [ @@ -1360,7 +1360,7 @@ }, { "cell_type": "markdown", - "id": "117", + "id": "118", "metadata": {}, "source": [ "### Using box prompts" @@ -1369,7 +1369,7 @@ { "cell_type": "code", "execution_count": null, - "id": "118", + "id": "119", "metadata": {}, "outputs": [], "source": [ @@ -1380,7 +1380,7 @@ { "cell_type": "code", "execution_count": null, - "id": "119", + "id": "120", "metadata": {}, "outputs": [], "source": [ @@ -1391,7 +1391,7 @@ { "cell_type": "code", "execution_count": null, - "id": "120", + "id": "121", "metadata": {}, "outputs": [], "source": [ @@ -1410,7 +1410,7 @@ { "cell_type": "code", "execution_count": null, - "id": "121", + "id": "122", "metadata": {}, "outputs": [], "source": [ @@ -1424,7 +1424,7 @@ { "cell_type": "code", "execution_count": null, - "id": "122", + "id": "123", "metadata": {}, "outputs": [], "source": [ @@ -1434,7 +1434,7 @@ { "cell_type": "code", "execution_count": null, - "id": "123", + "id": "124", "metadata": {}, "outputs": [], "source": [ @@ -1446,7 +1446,7 @@ { "cell_type": "code", "execution_count": null, - "id": "124", + "id": "125", "metadata": {}, "outputs": [], "source": [ @@ -1458,7 +1458,7 @@ }, { "cell_type": "markdown", - "id": "125", + "id": "126", "metadata": {}, "source": [ "![image](https://github.com/user-attachments/assets/0a9b794d-cf94-4e5c-9134-8799e67d338c)"