File: storing.rst

package info (click to toggle)
pgpointcloud 1.2.5-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,892 kB
  • sloc: sql: 40,767; ansic: 11,045; xml: 935; makefile: 297; cpp: 282; perl: 248; python: 178; sh: 92
file content (139 lines) | stat: -rw-r--r-- 4,761 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
******************************************************************************
Storing points
******************************************************************************

This tutorial is a basic introduction to pgPointcloud to store points in a
PostgreSQL database hosted on a Docker container.

------------------------------------------------------------------------------
Start Docker container
------------------------------------------------------------------------------

First we download the latest tag of the pgPoincloud Docker image:

.. code-block:: bash

  $ docker pull pgpointcloud/pointcloud

This Docker image is based on the official PostgreSQL image and the full
documentation is available `here`_.

For a basic usage, we have to define two environment variables:

+ the PostgreSQL database: ``POSTGRES_DB``
+ the PostgreSQL password: ``POSTGRES_PASSWORD``

Then we can start a new container:

.. code-block:: bash

  $ docker run --name pgpointcloud -e POSTGRES_DB=pointclouds -e POSTGRES_PASSWORD=mysecretpassword -d pgpointcloud/pointcloud

Extensions are automatically created in the new database named ``pointclouds``:

.. code-block:: bash

  $ docker exec -it pgpointcloud psql -U postgres -d pointclouds -c "\dx"
                                            List of installed extensions
          Name          | Version |   Schema   |                             Description
  ------------------------+---------+------------+---------------------------------------------------------------------
   fuzzystrmatch          | 1.1     | public     | determine similarities and distance between strings
   plpgsql                | 1.0     | pg_catalog | PL/pgSQL procedural language
   pointcloud             | 1.2.1   | public     | data type for lidar point clouds
   pointcloud_postgis     | 1.2.1   | public     | integration for pointcloud LIDAR data and PostGIS geometry data
   postgis                | 3.0.1   | public     | PostGIS geometry, geography, and raster spatial types and functions
   postgis_tiger_geocoder | 3.0.1   | tiger      | PostGIS tiger geocoder and reverse geocoder
   postgis_topology       | 3.0.1   | topology   | PostGIS topology spatial types and functions
  (7 rows)

.. _`here`: https://hub.docker.com/_/postgres

------------------------------------------------------------------------------
Run PDAL pipeline
------------------------------------------------------------------------------

For the need of the tutorial, we can download sample data from the `PDAL`_
organization:

.. code-block:: bash

  $ wget https://github.com/PDAL/data/raw/master/liblas/LAS12_Sample_withRGB_Quick_Terrain_Modeler_fixed.laz -P /tmp

Thanks to the ``pdal info`` command, we can obtain some information on the dataset:

+ Number of points: 3811489
+ Spatial reference: EPSG:32616

To configure the json PDAL pipeline, we need to set up the ``connection``
parameter for the ``pgpointcloud`` writer. To do that, the Docker container IP
adress on which the PostgreSQL database is running is necessary:

.. code-block:: bash

  $ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pgpointcloud
  172.17.0.2


So the ``pipeline.json`` file looks like:

.. code-block:: json

  {
    "pipeline":[
      {
        "type":"readers.las",
        "filename":"/tmp/LAS12_Sample_withRGB_Quick_Terrain_Modeler_fixed.laz"
      },
      {
        "type":"filters.chipper",
        "capacity":"400"
      },
      {
        "type":"writers.pgpointcloud",
        "connection":"host='172.17.0.2' dbname='pointclouds' user='postgres' password='mysecretpassword' port='5432'",
        "table":"airport",
        "compression":"dimensional",
        "srid":"32616"
      }
    ]
  }

The PDAL pipeline can finally be execute with ``pdal pipeline pipeline.json``
and an ``airport`` table is created.


.. _`PDAL`: https://github.com/PDAL

------------------------------------------------------------------------------
Configure connection service file
------------------------------------------------------------------------------

To facilitate the access to the database hosted on the Docker container, we can
configure the PostgreSQL connection service file:

.. code-block:: bash

  [pgpointcloud]
  host=172.17.0.2
  port=5432
  dbname=pointclouds
  user=postgres
  password=mysecretpassword

Then we can explore the content of the new ``airport`` table:

.. code-block:: bash

  $ psql service=pgpointcloud
  psql (12.3)
  Type "help" for help.

  pointclouds=# SELECT COUNT(*) FROM airport;
   count
  -------
    9529
  (1 row)

In this case, we have ``9529`` patchs containing ``400`` points (the size of
the chipper filter), meaning about ``3811600`` points. So the last patch isn't
fully filled.