Demo: View Point Cloud

This demo illustrates how to download and view a point cloud.

To run the demo, type:

$ python view_pointcloud.py

Purpose

This demo demonstrates how to download point cloud data within a specified bounding box and visualize it. The visualization colors the point cloud based on the z-coordinate, making it easier to see elevation variations.

Step-by-step

  1. Define Bounds: Specify the spatial bounds for a residential area in Helsingborg by setting a width/height value (here, 2000.0 units).

    h = 2000.0
    bounds = dtcc.Bounds(319891, 6399790, 319891 + h, 6399790 + h)
    
  2. Download the Point Cloud: Retrieve the point cloud data (lidar) for the defined bounds using the download_pointcloud function.

    pointcloud = dtcc.download_pointcloud(bounds=bounds)
    
  3. Visualize the Point Cloud: Extract the z-coordinate values from the point cloud and use these as color data when visualizing the point cloud via the view() method.

    color_data = pointcloud.points[:, 2]
    pointcloud.view(data=color_data)
    

Complete Code

Below is the complete code for this demo:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# This demo illustrates how to download and view a point cloud.

import dtcc

# Define bounds (a residential area in Helsingborg)
h = 2000.0
bounds = dtcc.Bounds(319891, 6399790, 319891 + h, 6399790 + h)

# Download point cloud
pointcloud = dtcc.download_pointcloud(bounds=bounds)

# View point cloud (color by z-coordinate)
color_data = pointcloud.points[:, 2]
pointcloud.view(data=color_data)