Forum

Author Topic: Coordinates of dense cloud points  (Read 4131 times)

Andy TMF

  • Newbie
  • *
  • Posts: 2
    • View Profile
Coordinates of dense cloud points
« on: October 30, 2024, 10:13:58 AM »
I haven't found a way to directly get point coordinates from cloud = chunk.point_clouds[0] in API version 2.1.3. So far I have to use the option via oc3-file, which is extremely inconvenient and time-consuming. Is there a faster and easier way? Thank you.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15429
    • View Profile
Re: Coordinates of dense cloud points
« Reply #1 on: October 30, 2024, 12:34:56 PM »
Hello Andy,

You can use PointCloud.Reader to get information related to the dense point cloud points.

See the simple example below that reads blocks by 1000 points from the point cloud and calculates geographic coordinates for each point.
Note that this example assumes that point cloud has same coordinate system as chunk and "lock transform" option is not applied to the point cloud.

Code: [Select]
chunk = Metashape.app.document.chunk
T = chunk.transform.matrix
crs = chunk.crs
point_cloud = chunk.point_cloud

pc_reader = Metashape.PointCloud.Reader()
pc_reader.open(point_cloud)

read_step = 1000 #read by 1000 points
n_points = point_cloud.point_count

for step in range(n_points // read_step + 1 * bool (n_points % read_step)):
points = pc_reader.read(read_step)
for point in points:
point_int = point.position
point_geo = crs.project(T.mulp(point_int))
pc_reader.reset()
Best regards,
Alexey Pasumansky,
Agisoft LLC

Andy TMF

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Coordinates of dense cloud points
« Reply #2 on: October 30, 2024, 01:22:33 PM »
I apologize, I have version 2.0.4 and the code you provided does not work, if only because

chunk = Metashape.app.document.chunk
AttributeError: 'NoneType' object has no attribute 'chunk'

And even if we use chunk = doc.chunk, which corresponds to 2.0.4, we have
pc_reader = Metashape.PointCloud.Reader()
AttributeError: type object 'Metashape.Metashape.PointCloud' has no attribute 'Reader'.

Is there a solution for version 2.0.4? Thank You.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15429
    • View Profile
Re: Coordinates of dense cloud points
« Reply #3 on: October 30, 2024, 02:06:22 PM »
Hello Andy,

PointCloud.Reader has been added to 2.1.3 API version.

For older versions you can use approach similar to the one described in your first post - export point cloud, then read it as an array.
Best regards,
Alexey Pasumansky,
Agisoft LLC