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

PointCloudLayer #322

Closed
3 of 4 tasks
kylebarron opened this issue Jan 17, 2024 · 8 comments
Closed
3 of 4 tasks

PointCloudLayer #322

kylebarron opened this issue Jan 17, 2024 · 8 comments
Assignees

Comments

@kylebarron
Copy link
Member

kylebarron commented Jan 17, 2024

@naomatheus was asking about using the PointCloudLayer in lonboard.

  • Expose multiple views to Python, so that advanced users can choose alternate views
  • Add PointCloudLayer to deck.gl-layers and then to lonboard. This is similar in most respects to the ScatterplotLayer, but it also has a getNormal accessor for point clouds specifically. (I have to do more research to understand exactly how this would be used)
  • Add example connecting to pdal

Note that the layer itself and the views are two distinct streams of work.

Tasks

Preview Give feedback
@kylebarron
Copy link
Member Author

Relevant comment for adding a new layer to lonboard: #302 (comment)

For PointCloudLayer, for getNormal we want to have a new type of "accessor" where the type is an Arrow FixedSizeList with size 3 and data type float32. Then we can pass that binary buffer into the getNormal param on the layer.

So in deck.gl-layers, we can create a new type called NormalAccessor that's defined as arrow.Vector<arrow.FixedSizeList<arrow.Float32>>.
https://github.com/geoarrow/deck.gl-layers/blob/b8cd17ad1b956420199b69faf138a44ae4d19e32/src/types.ts#L12-L14

Then create a new file, matching the types of the GeoArrowPointCloudLayer to the upstream layer props. E.g. with the scatterplot layer you can see our types and how they relate to the upstream parameters.

First create a PR there that we can discuss, and then after that we can go through how to add a new validator for this NormalAccessor data type, which allows us to create a new Python PointCloudLayer.

@kylebarron
Copy link
Member Author

Also note that PDAL has a list of dimensions that are available for each point. This getNormal in deck.gl corresponds to the Normal* dimensions there.

Name Type Description
NormalX double X component of a vector normal to surface at this point
NormalY double Y component of a vector normal to surface at this point
NormalZ double Z component of a vector normal to surface at this point

So when we load from PDAL, we can presumably get a numpy array for each dimension. We can interleave that into a 2D array with shape (3, N), where each "row" is [x, y, z]. That can be converted into Arrow memory and passed into lonboard

@naomatheus
Copy link
Contributor

So when we load from PDAL, we can presumably get a numpy array for each dimension. We can interleave that into a 2D array with shape (3, N), where each "row" is [x, y, z]. That can be converted into Arrow memory and passed into lonboard

What is the N in this 2d array in this case?

@naomatheus
Copy link
Contributor

  • With the point cloud layer, there are three accessors that we want to allow vectorization.
  • only allow single points because no point cloud layer should have multi-points (I think)
  • getNormal is the only new one. But I need to do some research into if the normal integers need to be normalized (if one must be one).

@naomatheus
Copy link
Contributor

naomatheus commented Jan 25, 2024

Also note that PDAL has a list of dimensions that are available for each point. This getNormal in deck.gl corresponds to the Normal* dimensions there.

Name Type Description
NormalX double X component of a vector normal to surface at this point
NormalY double Y component of a vector normal to surface at this point
NormalZ double Z component of a vector normal to surface at this point
So when we load from PDAL, we can presumably get a numpy array for each dimension. We can interleave that into a 2D array with shape (3, N), where each "row" is [x, y, z]. That can be converted into Arrow memory and passed into lonboard

Okay I think I get it. So the lonboard python interface would perform this flatten/interleave of the PDAL array shape.

The PDAL array shape is like... [[X],[Y],[Z]]. And converting that a numpy array of (3, N).... (3, [x,y,z])

@naomatheus
Copy link
Contributor

For PointCloudLayer, for getNormal we want to have a new type of "accessor" where the type is an Arrow FixedSizeList with size 3 and data type float32. Then we can pass that binary buffer into the getNormal param on the layer.

Non urgent question -
How did you know this? As in, I was asking the question... which arrow data type will work with this function...

@kylebarron
Copy link
Member Author

What is the N in this 2d array in this case?

The N is the number of rows.

import numpy as np
x = np.arange(0, 5)
y = np.arange(5, 10)
z = np.arange(10, 15)
points = np.vstack([x, y, z]).T
points
# array([[ 0,  5, 10],
#        [ 1,  6, 11],
#        [ 2,  7, 12],
#        [ 3,  8, 13],
#        [ 4,  9, 14]])
points.shape
# (5, 3)

The PDAL array shape is like... [[X],[Y],[Z]]. And converting that a numpy array of (3, N).... (3, [x,y,z])

Well, PDAL has its own integration with numpy. So you can probably access a pdal source in the form of points above. That's more efficient than creating a Python list of numbers.

I always get the axis ordering of shape confused, but I think the normal layout in "rows" is (N, 3) where you have N rows with 3 columns. So we'd be ensuring we have a numpy array of N rows by 3 (xyz) columns.

For PointCloudLayer, for getNormal we want to have a new type of "accessor" where the type is an Arrow FixedSizeList with size 3 and data type float32. Then we can pass that binary buffer into the getNormal param on the layer.

Non urgent question - How did you know this? As in, I was asking the question... which arrow data type will work with this function...

On the deck.gl side, floats are uploaded to the GPU as float32. Since it has x, y, and z values, it has size 3 per row. In Arrow, the memory underlying a FixedSizeList[3] is 100% equivalent to a numpy array of shape (N, 3), so they can be converted between representations freely.

@naomatheus naomatheus self-assigned this Jan 25, 2024
kylebarron added a commit that referenced this issue Mar 1, 2024
@kylebarron kylebarron changed the title PointCloudLayer and first-person views PointCloudLayer Mar 25, 2024
@kylebarron
Copy link
Member Author

Closed with #396

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants