pointtorch.io
Tools for reading and writing point cloud files.
- class pointtorch.io.CsvReader[source]
Bases:
BasePointCloudReader
Point cloud file reader for csv and txt files.
- read(
- file_path: str | Path,
- columns: List[str] | None = None,
- num_rows: int | None = None,
Reads a point cloud file.
- Parameters:
file_path – Path of the point cloud file to be read.
columns – Name of the point cloud columns to be read. The x, y, and z columns are always read.
num_rows – Number of rows to read. If set to
None
, all rows are read. Defaults toNone
.
- Returns:
Point cloud object.
- Raises:
ValueError – If the point cloud format is not supported by the reader.
- supported_file_formats() List[str] [source]
- Returns:
File formats supported by the point cloud file reader.
- class pointtorch.io.CsvWriter[source]
Bases:
BasePointCloudWriter
Point cloud file writer for csv and txt files.
- supported_file_formats() List[str] [source]
- Returns:
File formats supported by the point cloud file writer.
- write(
- point_cloud: PointCloudIoData,
- file_path: str | Path,
- columns: List[str] | None = None,
Writes a point cloud to a file.
- Parameters:
point_cloud – Point cloud to be written.
file_path – Path of the output file.
columns – Point cloud columns to be written. The x, y, and z columns are always written.
- Raises:
ValueError – If the point cloud format is not supported by the writer or if
columns
contains a column name that is not existing in the point cloud.
- class pointtorch.io.DownloadProgressBar(desc: str | None = None)[source]
Bases:
object
Progress bar showing the progress of file download.
- Parameters:
desc – Label of the progess bar. Defaults to
None
.
- class pointtorch.io.HdfReader[source]
Bases:
BasePointCloudReader
Point cloud file reader for h5 and hdf files.
- read(
- file_path: str | Path,
- columns: List[str] | None = None,
- num_rows: int | None = None,
Reads a point cloud file.
- Parameters:
file_path – Path of the point cloud file to be read.
columns – Name of the point cloud columns to be read. The x, y, and z columns are always read.
num_rows – Number of rows to read. If set to
None
, all rows are read. Defaults toNone
.
- Returns:
Point cloud object.
- Raises:
ValueError – If the point cloud format is not supported by the reader.
- supported_file_formats() List[str] [source]
- Returns:
File formats supported by the point cloud file reader.
- class pointtorch.io.HdfWriter[source]
Bases:
BasePointCloudWriter
Point cloud file writer for h5 and hdf files.
- supported_file_formats() List[str] [source]
- Returns:
File formats supported by the point cloud file writer.
- write(
- point_cloud: PointCloudIoData,
- file_path: str | Path,
- columns: List[str] | None = None,
Writes a point cloud to a file.
- Parameters:
point_cloud – Point cloud to be written.
file_path – Path of the output file.
columns – Point cloud columns to be written. The x, y, and z columns are always written.
- Raises:
ValueError – If the point cloud format is not supported by the writer or if
columns
contains a column name that is not existing in the point cloud.
- class pointtorch.io.LasReader(ignore_default_columns: bool = True)[source]
Bases:
BasePointCloudReader
Point cloud file reader for las and laz files.
- read(
- file_path: str | Path,
- columns: List[str] | None = None,
- num_rows: int | None = None,
Reads a point cloud file.
- Parameters:
file_path – Path of the point cloud file to be read.
columns – Name of the point cloud columns to be read. The x, y, and z columns are always read.
num_rows – Number of rows to read. If set to
None
, all rows are read. Defaults toNone
.
- Returns:
Point cloud object.
- Raises:
ValueError – If the point cloud format is not supported by the reader.
- supported_file_formats() List[str] [source]
- Returns:
File formats supported by the point cloud file reader.
- class pointtorch.io.LasWriter(maximum_resolution: float = 1e-06)[source]
Bases:
BasePointCloudWriter
Point cloud file writer for las and laz files.
- Parameters:
maximum_resolution – Maximum resolution of point coordinates in meter. Corresponds to the scale parameter used in the las/laz compression. Larger values result in a stronger compression and lower point cloud resolution. Defaults to \(10^{-6}\) m.
- Variables:
maximum_resolution – Maximum resolution of point coordinates in meter.
- supported_file_formats() List[str] [source]
- Returns:
File formats supported by the point cloud file writer.
- write(
- point_cloud: PointCloudIoData,
- file_path: str | Path,
- columns: List[str] | None = None,
Writes a point cloud to a file.
- Parameters:
point_cloud – Point cloud to be written.
file_path – Path of the output file.
columns – Point cloud columns to be written. The x, y, and z columns are always written.
- Raises:
ValueError – If the point cloud format is not supported by the writer or if
columns
contains a column name that is not existing in the point cloud.
- class pointtorch.io.PointCloudIoData(
- data: DataFrame,
- crs: str | None = None,
- identifier: str | None = None,
- x_max_resolution: float | None = None,
- y_max_resolution: float | None = None,
- z_max_resolution: float | None = None,
Bases:
object
Point cloud data structure used for I/O.
- class pointtorch.io.PointCloudReader[source]
Bases:
object
Point cloud file reader for csv, las, laz, and txt files.
- read(
- file_path: str | Path,
- columns: List[str] | None = None,
- num_rows: int | None = None,
Reads a point cloud file.
- Parameters:
file_path – Path of the point cloud file to be read.
columns – Name of the point cloud columns to be read. The x, y, and z columns are always read.
num_rows – Number of rows to read. If set to
None
, all rows are read. Defaults toNone
.
- Returns:
Point cloud object.
- Raises:
ValueError – If the point cloud format is not supported by the reader.
- supported_file_formats() List[str] [source]
- Returns:
File formats supported by the point cloud file reader.
- class pointtorch.io.PointCloudWriter[source]
Bases:
object
Point cloud file writer for csv, las, laz, and txt files.
- supported_file_formats() List[str] [source]
- Returns:
File formats supported by the point cloud file writer.
- write(
- point_cloud: PointCloudIoData,
- file_path: str | Path,
- columns: List[str] | None = None,
Writes a point cloud to a file.
- Parameters:
point_cloud – Point cloud to be written.
file_path – Path of the output file.
columns – Point cloud columns to be written. The x, y, and z columns are always written.
- Raises:
ValueError – If the point cloud format is not supported by the writer or if
columns
contains a column name that is not existing in the point cloud.
- pointtorch.io.download_file(
- url: str,
- file_path: str | Path,
- progress_bar: bool = True,
- progress_bar_desc: str | None = None,
Downloads a file via HTTP.
- Parameters:
url – The URL of the file to download.
file_path – Path where to save the downloaded file.
progress_bar – Whether a progress bar should be created to show the download progress. Defaults to
True
.progress_bar_desc – Description of the progress bar. Only used if
progress_bar
isTrue
. Defaults toNone
.
- Raises:
RuntimeError – If the file download fails.
- pointtorch.io.unzip(
- zip_path: str | Path,
- dest_path: str | Path,
- progress_bar: bool = True,
- progress_bar_desc: str | None = None,
Extracts all files from a zip archive.
- Parameters:
zip_path – Path of the zip archive.
dest_path – Path of the directory in which to save the extracted files. progress_bar: Whether a progress bar should be created to show the extraction progress. Defaults to
True
.progress_bar_desc – Description of the progress bar. Only used if
progress_bar
isTrue
. Defaults toNone
.
- Raises:
FileNotFoundError – If the zip file does not exist.