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

Pipeline from scala-constructed pointcloud #22

Open
kervel opened this issue Oct 25, 2019 · 7 comments
Open

Pipeline from scala-constructed pointcloud #22

kervel opened this issue Oct 25, 2019 · 7 comments
Labels
Milestone

Comments

@kervel
Copy link

kervel commented Oct 25, 2019

Hello,

i couldn't find documentation so far. My problem is that i have a dataset that can be converted to a pointcloud. I do the conversion as follows:

  def toPointCloud(sweeps: Seq[Tuple3[Coordinate, Double, Seq[XZ]]]): PointCloud = {
    // the Double in the tuple3 is the azimuth.
    val points = sweeps.map(gs => projectSweep(gs._3, gs._2, gs._1)).
          reduce((a,b) => DenseMatrix.horzcat(a,b))
    var v = new util.HashMap[String, SizedDimType]()
    v += "X" -> SizedDimType(DimType.X, java.lang.Double.BYTES, 0)
    v += "Y" -> SizedDimType(DimType.Y, java.lang.Double.BYTES, java.lang.Double.BYTES)
    v += "Z" -> SizedDimType(DimType.Z, java.lang.Double.BYTES, 2*java.lang.Double.BYTES)
    val bos = ByteBuffer.allocate(points.cols * points.rows * java.lang.Double.BYTES).order(ByteOrder.nativeOrder());
    val ios = bos.asDoubleBuffer();
    ios.put(points.copy.data)
    return new PointCloud(bos.array(), v)
  }

i verified and the pointcloud seems to be okay (i can get points out of it). I'd like to create a PDAL pipeline now using this pointcloud so that i can reproject/persist/... it.

Is there a way to do this ?

greetings,
Frank

@pomadchin
Copy link
Collaborator

Hey @kervel, so what is your question? How to use PDAL Pipeline, or how to transform points already loaded into memory?

If the first question, than you can do the following:

val pc: PipelineConstructor = LasRead("/path/to/las") ~ CropFilter() ~ SmthElse() ~ LasWrite("/path/to/new/las")
val pipeline = pc.toPipeline
pipeline.execute()
pipeline.getMetadata() // gets some metadata
val pvi = pipeline.getPointViews() // these are PDAL PointViews, views to get the actual pointclouds
val pc = pv.getPointCloud(0, Array(DimType.X, DimType.Y)) // this one will create a PointCloud object with the point 0 and x & y dims
pipeline.dispose()

In the example above we'll push the Pipeline to PDAL, it would process it, and return already transformed points.

If you want to do smth else with your pointclouds I would be happy to help you to start with https://github.com/geotrellis/geotrellis-pointcloud which exposes PDAL capabilities on Spark.

@pomadchin
Copy link
Collaborator

Ah, or you want to create a pointcloud object and to return back to PDAL to process it?

@kervel
Copy link
Author

kervel commented Oct 25, 2019

yes. i was hoping to use pdal to rasterize a pointcloud that i constructed using spark scala code (i have seen TinToDem also in geotrellis but for that i wouldn't even have to construct a pointcloud).
all the existing pdal examples start by loading an existing pointcloud from disk, and hence never face this problem...

@pomadchin
Copy link
Collaborator

pomadchin commented Oct 25, 2019

yea, so PDAL Pipeline interface only allows to perform transformations on read. So it is a sort of an IO interface in this case that allows to do transofmrations with pointclouds right after reading them from file.

PDAL does not expose an interface to provide some pointclouds represented as some in memory buffer as an input for PDAL Pipeline.

For your purposes for sure it is better to use TinToDem from geotrellis-pointcloud, it uses a nice delaunay triangulation implementation to perform it, so it may work.

I'm happy to help you with it! (if you would decide to touch geotrellis-pointcloud)

@abellgithub
Copy link

See https://pdal.io/stages/readers.memoryview.html

@pomadchin pomadchin added the enhancement New feature or request label Oct 26, 2019
@pomadchin
Copy link
Collaborator

Nice! Thanks for the pointer @abellgithub, I need to look into it.

@pomadchin
Copy link
Collaborator

This probably would be done in terms of a 2.0 release.

@pomadchin pomadchin added this to the future milestone Feb 29, 2020
@pomadchin pomadchin changed the title pipeline from scala-constructed pointcloud Pipeline from scala-constructed pointcloud Mar 3, 2020
@pomadchin pomadchin added feature and removed enhancement New feature or request labels Aug 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants