Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ LaspyReader for reading LAS/LAZ point cloud files #137

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

weiji14
Copy link
Owner

@weiji14 weiji14 commented Jan 30, 2024

An iterable-style DataPipe for point cloud data!

I/O handled using laspy.

Preview at https://zen3geo--137.org.readthedocs.build/en/137/api.html#module-zen3geo.datapipes.laspy

Usage:

from torchdata.datapipes.iter import IterableWrapper
from zen3geo.datapipes import LaspyReader

# Read in LAZ data using DataPipe
file_url: str = "https://opentopography.s3.sdsc.edu/pc-bulk/NZ19_Wellington/CL2_BQ31_2019_1000_2138.laz"
dp = IterableWrapper(iterable=[file_url])
_, dp_stream = dp.read_from_http().unzip(sequence_length=2)
dp_laspy = dp_stream.read_from_laspy()

# Loop or iterate over the DataPipe stream
it = iter(dp_laspy)
lasdata = next(it)
lasdata.header
# <LasHeader(1.4, <PointFormat(6, 0 bytes of extra dims)>)>
lasdata.xyz
# array([[ 1.74977156e+06,  5.42749877e+06, -7.24000000e-01],
#        [ 1.74977152e+06,  5.42749846e+06, -7.08000000e-01],
#        [ 1.74977148e+06,  5.42749815e+06, -7.00000000e-01],
#        ...,
#        [ 1.74976026e+06,  5.42756798e+06, -4.42000000e-01],
#        [ 1.74976029e+06,  5.42756829e+06, -4.17000000e-01],
#        [ 1.74976032e+06,  5.42756862e+06, -4.04000000e-01]])

Note that since laspy is made an optional dependency, users would need to do pip install zen3geo[lidar] to install the extra 'lidar' packages that includes laspy[lazrs].

TODO:

  • Add laspy as an optional dependency
  • Initial implementation of LaspyReaderIterDataPipe
  • Add unit tests to read COPC/LAS/LAZ files
  • Properly document new lidar extras

Native Python ASPRS LAS read/write library! Also using the lazrs backend.
An iterable-style DataPipe for reading LAS/LAZ point cloud files! Uses laspy (with either lazrs or laszip backend) for the I/O. Included a doctest that ensures a LAZ file from OpenTopography can be read. Added a new section in the API docs too.
@weiji14 weiji14 added the feature New feature or request label Jan 30, 2024
@weiji14 weiji14 added this to the 0.7.0 milestone Jan 30, 2024
@weiji14 weiji14 self-assigned this Jan 30, 2024
Ensure that LAS files can be read from disk, and LAZ/COPC files can be read from io.Bytes streaming from HTTP. Also updated docstring in LaspyReaderIterDataPipe to mention io.BytesIO as possible input type, and that COPC is supported too.
Optional LiDAR dependencies (laspy[lazrs]) can be installed via `pip install zen3geo[lidar]`.
@weiji14 weiji14 marked this pull request as ready for review February 2, 2024 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant