LiDAR PDAL – Addressing Precision Loss When Importing LAS Files with PDAL

laslidarpdalpgpointcloud

I check pdal info and see that bbox has 15 digit numbers:

"boundary": { "type": "Polygon", "coordinates": [ [ [ 1528634.540273188613355, 403421.710437842586543, 234.984 ], [ 1528634.540273188613355, 407979.483437842573039, 234.984 ], [ 1528834.540273188613355, 407979.483437842573039, 315.504 ], [ 1528834.540273188613355, 403421.710437842586543, 315.504 ], [ 1528634.540273188613355, 403421.710437842586543, 234.984 ] ] ] }

Then I imported this las file into pgpointcloud with this pipeline.json:

{
        "pipeline": [
            {
                "type":"readers.las",
                "filename":"%s"
            },
            {
                "type":"filters.chipper",
                "capacity":400
            },
            {
                "type": "writers.pgpointcloud",
                "connection":"%s",
                "table":"%s",
                "compression":"dimensional",
                "srid":"0",
            }
        ]
        }

The scheme in pointcloud_formats:

<pc:dimension>
  <pc:position>13</pc:position>
  <pc:size>8</pc:size>
  <pc:description>X coordinate</pc:description>
  <pc:name>X</pc:name>
  <pc:interpretation>double</pc:interpretation>
  <pc:active>true</pc:active>
 </pc:dimension>
 <pc:dimension>
  <pc:position>14</pc:position>
  <pc:size>8</pc:size>
  <pc:description>Y coordinate</pc:description>
  <pc:name>Y</pc:name>
  <pc:interpretation>double</pc:interpretation>
  <pc:active>true</pc:active>
 </pc:dimension>

And finally coordinates in table

with pts as(
    select PC_Explode(pa) as pt
    from "Blocks"
    where id = 100000
)
select 
     PC_Get(pt, 'X') as "x"
    ,PC_Get(pt, 'Y') as "y"
from pts
order by PC_Get(pt, 'Z');
-------------------------
x                   y
1531507.46827319    404533.469437843
1531507.47027319    404533.577437843
...

So in imported table precision is 8 digit numbers.

After I added both, the table and the las file in QGIS and found that the same point very very close but not exactly the same.

So did I lose precision? And how to prevent this?

Best Answer

You can preserve the precision by setting the scale factors in the point cloud writer, try adding these just below "type": "writers.pgpointcloud" :

        "scale_x":"0.000000000000001",
        "scale_y":"0.000000000000001",

From the docs: enter image description here

Function docs: https://pdal.io/stages/writers.pgpointcloud.html