{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Working with LAS and PCD Files\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "It's possible to read pointcloud files with the format .las and .pcd. In order to read them just the submodule PointCloud.from_file():" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from pathlib import Path\n", "\n", "import laspy\n", "import numpy as np\n", "\n", "import pointcloudset as pcs" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "testpcd = Path().cwd().parent.joinpath(\"../../../tests/testdata/las_files/test_tree.pcd\")\n", "testlas = testpcd = Path().cwd().parent.joinpath(\"../../../tests/testdata/las_files/test_tree.las\")\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "las_pc = pcs.PointCloud.from_file(testlas)\n", "pcd_pc = pcs.PointCloud.from_file(testpcd)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Note:\n", "Coordinates might not be correct yet, since the offset and scale values that are stored within the .las-file are not applied.\n", "But now you can use the data as a pcs.PointCloud and analyze + edit it. \n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "las_pc.data" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "las_pc.plot(color=\"z\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def treetop(frame: pcs.PointCloud) -> pcs.PointCloud:\n", " return frame.limit(\"z\", 8, 19)\n", "\n", "\n", "tip = treetop(las_pc)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "tip.plot(color=\"z\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "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.11.10" }, "orig_nbformat": 2 }, "nbformat": 4, "nbformat_minor": 2 }