|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "id": "d4f53ca1-2726-4c0c-af0b-d39831237087", |
| 6 | + "metadata": {}, |
| 7 | + "source": [ |
| 8 | + "# Point Cloud Data Visualization with a classes slider\n", |
| 9 | + "\n", |
| 10 | + "* Download point cloud data\n", |
| 11 | + "* Create a sparse TileDB array\n", |
| 12 | + "* Visualize the point cloud with a classes slider\n", |
| 13 | + "* Customize with optional parameters" |
| 14 | + ] |
| 15 | + }, |
| 16 | + { |
| 17 | + "cell_type": "code", |
| 18 | + "execution_count": null, |
| 19 | + "id": "c33b9bc9-cb24-4064-b8ec-61b1b332a266", |
| 20 | + "metadata": {}, |
| 21 | + "outputs": [], |
| 22 | + "source": [ |
| 23 | + "import requests\n", |
| 24 | + "\n", |
| 25 | + "import pdal\n", |
| 26 | + "from pybabylonjs import Show as show\n", |
| 27 | + "import tiledb" |
| 28 | + ] |
| 29 | + }, |
| 30 | + { |
| 31 | + "cell_type": "markdown", |
| 32 | + "id": "fb67c477-5b04-4fd8-bec7-a286e7ae92a2", |
| 33 | + "metadata": {}, |
| 34 | + "source": [ |
| 35 | + "## Optional: create a sparse TileDB array from a LAZ file" |
| 36 | + ] |
| 37 | + }, |
| 38 | + { |
| 39 | + "cell_type": "code", |
| 40 | + "execution_count": null, |
| 41 | + "id": "f9eb5905-32a5-49e6-9b96-d89a701f91f9", |
| 42 | + "metadata": {}, |
| 43 | + "outputs": [], |
| 44 | + "source": [ |
| 45 | + "!wget -nc \"https://github.com/PDAL/data/blob/master/autzen/autzen-classified.laz?raw=true\" -O \"autzen-classified.laz\"" |
| 46 | + ] |
| 47 | + }, |
| 48 | + { |
| 49 | + "cell_type": "code", |
| 50 | + "execution_count": null, |
| 51 | + "id": "d878a610-ad6f-4796-bf25-1c2f1c4d31c9", |
| 52 | + "metadata": {}, |
| 53 | + "outputs": [], |
| 54 | + "source": [ |
| 55 | + "pipeline = (\n", |
| 56 | + " pdal.Reader(\"autzen-classified.laz\") |\n", |
| 57 | + " pdal.Filter.stats() |\n", |
| 58 | + " pdal.Writer.tiledb(array_name=\"autzen-classified\",chunk_size=100000)\n", |
| 59 | + ")\n", |
| 60 | + "\n", |
| 61 | + "count = pipeline.execute() " |
| 62 | + ] |
| 63 | + }, |
| 64 | + { |
| 65 | + "cell_type": "code", |
| 66 | + "execution_count": null, |
| 67 | + "id": "77cd7fd4-9e77-4307-bb7a-c828a9395530", |
| 68 | + "metadata": {}, |
| 69 | + "outputs": [], |
| 70 | + "source": [ |
| 71 | + "lidar_array = \"autzen-classified\"" |
| 72 | + ] |
| 73 | + }, |
| 74 | + { |
| 75 | + "cell_type": "markdown", |
| 76 | + "id": "300faf9b-716e-4c3c-af00-86d9cf118b39", |
| 77 | + "metadata": {}, |
| 78 | + "source": [ |
| 79 | + "To load and display a slice of the data a bounding box with the minimum and maximum values of X, Y and Z are needed:" |
| 80 | + ] |
| 81 | + }, |
| 82 | + { |
| 83 | + "cell_type": "code", |
| 84 | + "execution_count": null, |
| 85 | + "id": "7aa48a9d-9aba-4919-8ed6-3fea268b5bf4", |
| 86 | + "metadata": {}, |
| 87 | + "outputs": [], |
| 88 | + "source": [ |
| 89 | + "bbox = {\n", |
| 90 | + " 'X': [636800, 637800],\n", |
| 91 | + " 'Y': [851000, 853000],\n", |
| 92 | + " 'Z': [406.14, 615.26]\n", |
| 93 | + "}" |
| 94 | + ] |
| 95 | + }, |
| 96 | + { |
| 97 | + "cell_type": "markdown", |
| 98 | + "id": "e179da13-10d4-42c6-ad8e-7850339eee2e", |
| 99 | + "metadata": {}, |
| 100 | + "source": [ |
| 101 | + "### Visualize the point cloud with a classes slider\n", |
| 102 | + "\n", |
| 103 | + "*The below example loads the data from a local array, but a time slider can be added to point clouds from all data sources: `local`, `cloud` and `dict`.*\n", |
| 104 | + "\n", |
| 105 | + "Point cloud data from the local array can be loaded and displayed with the below, where `uri` is the location of the array:" |
| 106 | + ] |
| 107 | + }, |
| 108 | + { |
| 109 | + "cell_type": "code", |
| 110 | + "execution_count": null, |
| 111 | + "id": "29b8b806-b785-4784-a802-d5d7d735a12a", |
| 112 | + "metadata": {}, |
| 113 | + "outputs": [], |
| 114 | + "source": [ |
| 115 | + "show.point_cloud(source=\"local\",\n", |
| 116 | + " mode=\"default\",\n", |
| 117 | + " uri=lidar_array,\n", |
| 118 | + " bbox = bbox)" |
| 119 | + ] |
| 120 | + }, |
| 121 | + { |
| 122 | + "cell_type": "markdown", |
| 123 | + "id": "e06eaa47-7277-419f-b204-69c8418628ee", |
| 124 | + "metadata": {}, |
| 125 | + "source": [ |
| 126 | + "To add a time slider change the mode from `default` to `classes` and add the `classes` variable that contains the names for each class. Also make sure there is an attribute `Classification` in the array:" |
| 127 | + ] |
| 128 | + }, |
| 129 | + { |
| 130 | + "cell_type": "code", |
| 131 | + "execution_count": null, |
| 132 | + "id": "95fc9ca9-19b5-4872-9369-3473bd286442", |
| 133 | + "metadata": {}, |
| 134 | + "outputs": [], |
| 135 | + "source": [ |
| 136 | + "classes = {\n", |
| 137 | + " 'numbers': [0,2,5,6,9,15,17,19,64,65,66,67,68,69,70,71,72,73,74,75,76,77],\n", |
| 138 | + " 'names': ['None','Ground','Vegetation','Building','Water','Transmission Tower',\n", |
| 139 | + " 'Bridge Deck','Overhead Structure','Wire','Car','Truck','Boat',\n", |
| 140 | + " 'Barrier','Railroad car','Elevated Walkway','Covered Walkway',\n", |
| 141 | + " 'Pier/Dock','Fence','Tower','Crane','Silo/Storage Tank','Bridge Structure']\n", |
| 142 | + "}\n", |
| 143 | + "\n", |
| 144 | + "show.point_cloud(source=\"local\",\n", |
| 145 | + " mode=\"classes\",\n", |
| 146 | + " uri=lidar_array,\n", |
| 147 | + " bbox = bbox,\n", |
| 148 | + " classes=classes)" |
| 149 | + ] |
| 150 | + }, |
| 151 | + { |
| 152 | + "cell_type": "markdown", |
| 153 | + "id": "435491c9-1093-4c6a-b67f-6f35047e7b15", |
| 154 | + "metadata": {}, |
| 155 | + "source": [ |
| 156 | + "## Customize with optional parameters" |
| 157 | + ] |
| 158 | + }, |
| 159 | + { |
| 160 | + "cell_type": "code", |
| 161 | + "execution_count": null, |
| 162 | + "id": "c54a3e7a-7edf-4412-a018-b570481f9381", |
| 163 | + "metadata": {}, |
| 164 | + "outputs": [], |
| 165 | + "source": [ |
| 166 | + "show.point_cloud(source=\"local\",\n", |
| 167 | + " mode=\"classes\",\n", |
| 168 | + " uri=lidar_array,\n", |
| 169 | + " bbox = bbox,\n", |
| 170 | + " classes=classes,\n", |
| 171 | + " width=1200,\n", |
| 172 | + " height=800,\n", |
| 173 | + " z_scale=1.5,\n", |
| 174 | + " color_scheme=\"blue\")" |
| 175 | + ] |
| 176 | + }, |
| 177 | + { |
| 178 | + "cell_type": "code", |
| 179 | + "execution_count": null, |
| 180 | + "id": "3f29c476-0dfa-43e8-8eb2-9b680a04da4d", |
| 181 | + "metadata": {}, |
| 182 | + "outputs": [], |
| 183 | + "source": [] |
| 184 | + } |
| 185 | + ], |
| 186 | + "metadata": { |
| 187 | + "kernelspec": { |
| 188 | + "display_name": "Python 3 (ipykernel)", |
| 189 | + "language": "python", |
| 190 | + "name": "python3" |
| 191 | + }, |
| 192 | + "language_info": { |
| 193 | + "codemirror_mode": { |
| 194 | + "name": "ipython", |
| 195 | + "version": 3 |
| 196 | + }, |
| 197 | + "file_extension": ".py", |
| 198 | + "mimetype": "text/x-python", |
| 199 | + "name": "python", |
| 200 | + "nbconvert_exporter": "python", |
| 201 | + "pygments_lexer": "ipython3", |
| 202 | + "version": "3.7.10" |
| 203 | + } |
| 204 | + }, |
| 205 | + "nbformat": 4, |
| 206 | + "nbformat_minor": 5 |
| 207 | +} |
0 commit comments