ds.rst.to_pointcloud() or Raster.to_pointcloud()#
- RasterBase.to_pointcloud(data_name='b1', data_band=1, auxiliary_data_bands=None, auxiliary_column_names=None, subsample=1, skip_nodata=True, as_array=False, random_state=None, force_pixel_offset='center', mp_config=None, force_output_to_memory=False, pointcloud_return_type=None)[source]#
Convert raster cells to a point cloud, optionally selecting a random subsample.
- Overloads:
data_name (
str) ='b1', data_band (int) =1, auxiliary_data_bands (Iterable[int] |None) =None, auxiliary_column_names (Iterable[str] |None) =None, subsample (float|int) =1, skip_nodata (bool) =True, *, as_array (Literal[False]) =False, random_state (int|Generator|None) =None, force_pixel_offset (Literal['center','ul','ur','ll','lr']) ='center', mp_config (MultiprocConfig|None) =None, force_output_to_memory (bool) =False, pointcloud_return_type (Literal['dataarray']) →DataArraydata_name (
str) ='b1', data_band (int) =1, auxiliary_data_bands (Iterable[int] |None) =None, auxiliary_column_names (Iterable[str] |None) =None, subsample (float|int) =1, skip_nodata (bool) =True, *, as_array (Literal[False]) =False, random_state (int|Generator|None) =None, force_pixel_offset (Literal['center','ul','ur','ll','lr']) ='center', mp_config (MultiprocConfig|None) =None, force_output_to_memory (bool) =False, pointcloud_return_type (Literal['geodataframe']) →GeoDataFramedata_name (
str) ='b1', data_band (int) =1, auxiliary_data_bands (Iterable[int] |None) =None, auxiliary_column_names (Iterable[str] |None) =None, subsample (float|int) =1, skip_nodata (bool) =True, *, as_array (Literal[True]), random_state (int|Generator|None) =None, force_pixel_offset (Literal['center','ul','ur','ll','lr']) ='center', mp_config (MultiprocConfig|None) =None, force_output_to_memory (bool) =False, pointcloud_return_type (Optional[Literal['dataarray','dataset','geodataframe']]) =None→NDArray[Union[floating[Any],integer[Any]]]data_name (
str) ='b1', data_band (int) =1, auxiliary_data_bands (Iterable[int] |None) =None, auxiliary_column_names (Iterable[str] |None) =None, subsample (float|int) =1, skip_nodata (bool) =True, *, as_array (bool) =False, random_state (int|Generator|None) =None, force_pixel_offset (Literal['center','ul','ur','ll','lr']) ='center', mp_config (MultiprocConfig|None) =None, force_output_to_memory (bool) =False, pointcloud_return_type (Optional[Literal['dataarray','dataset','geodataframe']]) =None→NDArray[Union[floating[Any],integer[Any]]] |PointCloud|DataArray|Dataset|GeoDataFrame
Cell selection and output construction use the same implementation as subsample(). With the default
subsample=1, every eligible cell is returned, while this method keeps conversion arguments first.- Parameters:
data_name (
str) – Name to use for point cloud data attribute, defaults to “bX” where X is the data band number.data_band (
int) – (Only for multi-band rasters) Band to use for data attribute, defaults to first. Band counting starts at 1.auxiliary_data_bands (
Iterable[int] |None) – (Only for multi-band rasters) Other bands to save as auxiliary data attributes, defaulting to every band other thandata_band. Pass an empty iterable to keep only the main band.auxiliary_column_names (
Iterable[str] |None) – (Only for multi-band rasters) Names to use for auxiliary data bands, only if auxiliary data bands is not none, defaults to “b1”, “b2”, etc.subsample (
float|int) – Fraction or maximum number of eligible cells to return, with 1 selecting every cell.skip_nodata (
bool) – Whether to skip nodata values.as_array (
bool) – Return an array instead of a vector.random_state (
int|Generator|None) – Random state or seed number.force_pixel_offset (
Literal['center','ul','ur','ll','lr']) – Pixel position used to calculate each point coordinate. Defaults to “center”; explicit corner positions are “ul”, “ur”, “ll” and “lr”.mp_config (
MultiprocConfig|None) – Worker, tile and output settings for multiprocessing. Point output uses GeoPackage, LAS or LAZ; LAS/LAZ stores the main raster value as elevation. Array output does not write a file. Cannot be combined with a Dask source.force_output_to_memory (
bool) – Keep the complete output in memory instead of using the automatic chunked path.pointcloud_return_type (
Optional[Literal['dataarray','dataset','geodataframe']]) – Returned representation: dataarray, dataset, or geodataframe. None uses config[“pointcloud_return_type”] for accessors, or returns a PointCloud for GeoUtils objects.
- Raises:
ValueError – If the sample count or fraction is poorly formatted.
- Returns:
A point cloud, or array of the shape (N, 2 + count) where N is the sample count.