pointcloud
pointcloud : data type for lidar point clouds
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 1520 | pointcloud | pointcloud | 1.2.5 |
GIS | BSD-3-Clause | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --s-d-- | No | Yes | No | Yes | no | no |
| Relationships | |
|---|---|
| Need By | pointcloud_postgis |
| See Also | postgis_raster pgh_raster ogr_fdw pgrouting pg_sphere q3c mobilitydb h3 |
| Siblings | pointcloud_postgis |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PGDG | 1.2.5 |
18 17 16 15 14 | pointcloud |
- |
| RPM | PGDG | 1.2.5 |
18 17 16 15 14 | pointcloud_$v |
- |
| DEB | PGDG | 1.2.5 |
18 17 16 15 14 | postgresql-$v-pointcloud |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 |
| el8.aarch64 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 |
| el9.x86_64 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 |
| el9.aarch64 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 |
| el10.x86_64 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 |
| el10.aarch64 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 |
| d12.x86_64 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 |
| d12.aarch64 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 |
| d13.x86_64 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 |
| d13.aarch64 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 |
| u22.x86_64 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 |
| u22.aarch64 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 |
| u24.x86_64 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 |
| u24.aarch64 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 |
| u26.x86_64 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 |
| u26.aarch64 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 | PGDG 1.2.5 |
Source
github.com/pgpointcloud/pointcloud
pointcloud-1.2.5.tar.gz
Install
Make sure PGDG repo available:
Install this extension with pig:
Create this extension with:
Usage
pgpointcloud/pointcloud: A PostgreSQL extension for storing point cloud (LIDAR) data
PostgreSQL Pointcloud stores point cloud (LIDAR) data in PostgreSQL. It introduces
two new data types: PcPoint for individual points and PcPatch for collections
of points. Data is organized by schema documents that describe the dimensions and
encoding of each point.
Concepts
Schemas
PostgreSQL Pointcloud uses a “schema document” to describe the contents of any particular LIDAR point. Each point contains a number of dimensions, and each dimension can be of any data type, with scaling and/or offsets applied to move between the actual value and the value stored in the database. The schema document format is the same one used by the PDAL library.
Here is a simple 4-dimensional schema document:
Schema documents are stored in the pointcloud_formats table, along with apcid or “pointcloud identifier”. Each object just has a pcid, which serves
as a key to find the schema in pointcloud_formats. This is similar to the way
the srid is resolved for spatial reference system support in PostGIS.
Point Cloud Objects
PcPoint: The basic point cloud type. Every point has a (large) number of
dimensions, but at a minimum an X and Y coordinate. Points can be rendered in
JSON form using PC_AsText(pcpoint):
PcPatch: A collection of PcPoint grouped together. Instead of storing
billions of individual point records, LIDAR data is represented as a smaller
collection of PcPatch records. Patches are rendered with PC_AsText(pcpatch):
Tables
Two system-provided tables are available:
pointcloud_formats: holds all the pcid entries and schema documentspointcloud_columns: a view displaying all columns that contain point cloud objects
Compressions
Compression is declared in the <pc:metadata> block of the schema document:
Three supported compression methods:
- None: stores points and patches as byte arrays using type and formats described in the schema document.
- Dimensional: stores patches as collections of dimensional data arrays with “appropriate” compression applied. Makes the most sense for smaller patch sizes.
- LAZ (LASZip): requires Pointcloud built with laz-perf support.
If no compression is declared, none is assumed.
Dimensional compression uses three schemes internally: run-length encoding (for low variability), common bits removal (for narrow bit range variability), and raw deflate compression via zlib.
Functions: Schema
PC_SchemaGetNDims
PC_SchemaGetNDims(pcid integer) returns integer – Return the number of dimensions.
PC_SchemaIsValid
PC_SchemaIsValid(xml text) returns boolean – Return true if the pointcloud schema is valid.
Functions: PcPoint
PC_MakePoint
PC_MakePoint(pcid integer, vals float8[]) returns pcpoint – Construct a new pcpoint from a pcid and array of doubles.
Insert test values:
PC_AsText (point)
PC_AsText(p pcpoint) returns text – Returns a JSON version of the point data.
PC_Get
PC_Get(pt pcpoint) returns float8[] – Returns values of all dimensions in an array.
PC_Get(pt pcpoint, dimname text) returns numeric – Returns the value of a named dimension.
PC_MemSize (point)
PC_MemSize(pt pcpoint) returns int4 – Returns the memory size of a pcpoint.
PC_PCId (point)
PC_PCId(p pcpoint) returns integer – Returns the pcid schema number of this point.
Functions: PcPatch
PC_Patch
PC_Patch(pts pcpoint[]) returns pcpatch – Aggregate function that collects pcpoint values into a pcpatch.
PC_MakePatch
PC_MakePatch(pcid integer, vals float8[]) returns pcpatch – Construct a new pcpatch from a pcid and array of doubles (array size must be a multiple of dimension count).
PC_AsText (patch)
PC_AsText(p pcpatch) returns text – Returns a JSON version of the patch data.
PC_Summary
PC_Summary(p pcpatch) returns text – Returns a JSON formatted summary of the patch data.
PC_NumPoints
PC_NumPoints(p pcpatch) returns integer – Returns the number of points in a patch.
PC_PCId (patch)
PC_PCId(p pcpatch) returns integer – Returns the pcid schema number of the patch.
PC_MemSize (patch)
PC_MemSize(p pcpatch) returns int4 – Returns the memory size of a pcpatch.
PC_Explode
PC_Explode(p pcpatch) returns SetOf[pcpoint] – Set-returning function converting a patch to individual point records.
PC_PointN
PC_PointN(p pcpatch, n int4) returns pcpoint – Returns the n-th point (1-based). Negative n counts from the end.
PC_Range
PC_Range(p pcpatch, start int4, n int4) returns pcpatch – Returns a patch containing n points starting from the start-th point (1-based).
PC_Union
PC_Union(p pcpatch[]) returns pcpatch – Aggregate function that merges pcpatch entries into a single pcpatch.
PC_Intersects (patch-patch)
PC_Intersects(p1 pcpatch, p2 pcpatch) returns boolean – Returns true if the bounds of p1 intersect the bounds of p2.
PC_PatchAvg
PC_PatchAvg(p pcpatch, dimname text) returns numeric – Returns the average value of a named dimension across all points.
PC_PatchAvg(p pcpatch) returns pcpoint – Returns a PcPoint with average values of each dimension.
PC_PatchMin
PC_PatchMin(p pcpatch, dimname text) returns numeric – Returns the minimum value of a named dimension.
PC_PatchMin(p pcpatch) returns pcpoint – Returns a PcPoint with the minimum values of each dimension.
PC_PatchMax
PC_PatchMax(p pcpatch, dimname text) returns numeric – Returns the maximum value of a named dimension.
PC_PatchMax(p pcpatch) returns pcpoint – Returns a PcPoint with the maximum values of each dimension.
PC_FilterGreaterThan
PC_FilterGreaterThan(p pcpatch, dimname text, float8 value) returns pcpatch – Filter points with values greater than the given value.
PC_FilterLessThan
PC_FilterLessThan(p pcpatch, dimname text, float8 value) returns pcpatch – Filter points with values less than the given value.
PC_FilterEquals
PC_FilterEquals(p pcpatch, dimname text, float8 value) returns pcpatch – Filter points with values equal to the given value.
PC_FilterBetween
PC_FilterBetween(p pcpatch, dimname text, float8 value1, float8 value2) returns pcpatch – Filter points with values between (excluding) value1 and value2.
PC_Sort
PC_Sort(p pcpatch, dimnames text[]) returns pcpatch – Returns a copy of the patch lexicographically sorted along the given dimensions.
PC_IsSorted
PC_IsSorted(p pcpatch, dimnames text[], strict boolean default true) returns boolean – Checks whether a pcpatch is sorted lexicographically. The strict option checks for no duplicates.
PC_SetPCId
PC_SetPCId(p pcpatch, pcid int4, def float8 default 0.0) returns pcpatch – Sets the schema on a PcPatch. For dimensions in the new schema but not in the old, the value def is used (default 0.0).
PC_Transform
PC_Transform(p pcpatch, pcid int4, def float8 default 0.0) returns pcpatch – Returns a new patch with data transformed based on the target schema. Unlike PC_SetPCId, this may change patch data if interpretations, scales or offsets differ.
PC_Compress
PC_Compress(p pcpatch, global_compression_scheme text, compression_config text) returns pcpatch – Compress a patch with a manually specified scheme.
Allowed global compression schemes: auto, laz, dimensional. For dimensional, the config is a comma-separated list of per-dimension compressions: auto, zlib, sigbits, rle.
PC_Uncompress
PC_Uncompress(p pcpatch) returns pcpatch – Returns an uncompressed version (compression type none). Must be the outer function in your query to return uncompressed data on the wire.
Functions: WKB
PC_AsBinary (point)
PC_AsBinary(p pcpoint) returns bytea – Return the OGC “well-known binary” format for the point.
PC_EnvelopeAsBinary
PC_EnvelopeAsBinary(p pcpatch) returns bytea – Return the OGC WKB for the 2D bounds of the patch.
Note: PC_Envelope is a deprecated alias for PC_EnvelopeAsBinary.
PC_BoundingDiagonalAsBinary
PC_BoundingDiagonalAsBinary(p pcpatch) returns bytea – Return the OGC WKB for the bounding diagonal of the patch.
Functions: PostGIS Integration
The pointcloud_postgis extension adds functions for using Pointcloud with PostGIS, converting PcPoint and PcPatch to Geometry and doing spatial filtering.
Geometry Cast
Geometry(pcpoint) returns geometry / pcpoint::geometry – Casts PcPoint to PostGIS geometry, mapping x/y/z/m.
PC_EnvelopeGeometry
PC_EnvelopeGeometry(pcpatch) returns geometry – Returns the 2D bounds as a PostGIS Polygon 2D.
Useful for creating an index:
PC_BoundingDiagonalGeometry
PC_BoundingDiagonalGeometry(pcpatch) returns geometry – Returns the bounding diagonal as a LineString (2D/Z/M/ZM based on available dimensions).
Useful for creating a ND index:
PC_Intersection
PC_Intersection(pcpatch, geometry) returns pcpatch – Returns a PcPatch containing only points that intersect the geometry.
PC_Intersects (patch-geometry)
PC_Intersects(p pcpatch, g geometry) returns boolean / PC_Intersects(g geometry, p pcpatch) returns boolean – Returns true if the bounds of the patch intersect the geometry.
Functions: Utils
PC_Version / PC_Lib_Version / PC_Script_Version
PC_Lazperf_Enabled
PC_Lazperf_Enabled() returns boolean – Returns true if LAZperf compression support is available.
Loading Data with PDAL
PDAL is used to load LIDAR files into PostgreSQL Pointcloud. A PDAL pipeline is a JSON file declaring readers, filters, and writers.
Example pipeline to load a LAS file:
Execute with:
The filters.chipper groups unordered points into compact patches for efficient storage.
PDAL Writer Options
- connection: PostgreSQL connection string
- table: Table to write patches to
- schema: Schema to create the table in (optional)
- column: Column name for patches (default:
pa) - compression: Patch compression format (default:
dimensional) - overwrite: Replace any existing table (default:
true) - srid: Spatial reference id (default:
4326) - pcid: An existing PCID to use (optional)
- pre_sql / post_sql: SQL to execute before/after pipeline (optional)
PDAL Reader Options
- connection: PostgreSQL connection string
- table: Table to read patches from
- schema: Schema to read from (optional)
- column: Column name to read (default:
pa) - where: SQL where clause to constrain the query (optional)
- spatialreference: Override the database SRID (optional)
Example pipeline to read and export: