pc: Point cloud data utilities¶
moraine.api.pc(源码)。每个名字也是 moraine.<name>(import moraine as mr)。
pc_hix
¶
Compute the hillbert index for point cloud data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gix
|
grid index |
required | |
shape
|
tuple
|
(nlines, width) |
required |
pc_gix
¶
convert hillbert index to grid index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hix
|
hillbert index |
required | |
shape
|
tuple
|
(nlines, width) |
required |
pc_sort
¶
Get the indices that sort the input.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
ndarray
|
unsorted |
required |
shape
|
tuple
|
(nline, width), faster if provided for grid index input |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
indices that sort input |
pc2ras
¶
convert point cloud data to original raster, filled with nan
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
ndarray
|
gix or hix array |
required |
pc_data
|
ndarray
|
data, 1D or more |
required |
shape
|
tuple
|
image shape |
required |
pc_union
¶
Get the union of two point cloud dataset. For points at their intersection, prefer idx1 rather than idx2
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx1
|
ndarray
|
int array, grid index or hillbert index of the first point cloud, sorted, without duplicates |
required |
idx2
|
ndarray
|
int array, grid index or hillbert index of the second point cloud, sorted, without duplicates |
required |
shape
|
tuple
|
image shape, faster if provided for grid index input |
None
|
Returns:
| Type | Description |
|---|---|
tuple
|
|
pc_intersect
¶
Get the intersection of two point cloud dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx1
|
ndarray
|
int array, grid index or hillbert index of the first point cloud, sorted, without duplicates |
required |
idx2
|
ndarray
|
int array, grid index or hillbert index of the second point cloud, sorted, without duplicates |
required |
shape
|
tuple
|
image shape, faster if provided for grid index input |
None
|
Returns:
| Type | Description |
|---|---|
tuple
|
|
pc_diff
¶
Get the point cloud in idx1 that are not in idx2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx1
|
ndarray
|
int array, grid index or hillbert index of the first point cloud, sorted, without duplicates |
required |
idx2
|
ndarray
|
int array, grid index or hillbert index of the second point cloud, sorted, without duplicates |
required |
shape
|
tuple
|
image shape, faster if provided for grid index input |
None
|
Returns:
| Type | Description |
|---|---|
tuple
|
|
示例¶
构建本手册时运行;输出紧随每段代码。
import numpy as np
import moraine as mr
shape = (8, 8) # (nlines, width) of the raster
gix1 = np.array([[0, 1], [2, 3], [5, 5]], dtype=np.int32) # (azimuth, range) of three points
hix1 = mr.pc_hix(gix1, shape) # hilbert index of each point
print(hix1)
order = mr.pc_sort(hix1) # point clouds are kept in hilbert order
hix1, gix1 = hix1[order], gix1[order]
gix2 = np.array([[2, 3], [7, 0]], dtype=np.int32)
hix2 = np.sort(mr.pc_hix(gix2, shape))
hix, in1, in2, new2 = mr.pc_union(hix1, hix2) # sorted inputs, sorted union
print(hix, mr.pc_gix(hix, shape).tolist())
print(in1, in2, new2) # where the points of each input went