Module Query
See also
opals::IQuery

Aim of module

Interpolates height or attribute values for arbitrary 2D geometries based on either point clouds (not yet implemented) or grids.

General description

opalsQuery reads in 2D geometries in OGC Well-Known-Text (WKT) format and interpolates values (height or attribute) based on a set of point clouds (not yet implemented) or rasters. The result is again an OGC geometry in WKT syntax containing the interpolated values as height (Z) or attribute (M).

See also
Module Query

Diskussion des Konzeptes:

opalsQuery stellt ein Modul dar, welches Höhen- oder Attributwerte an beliebigen Stellen und auf Basis von beliebig vielen Input-Datensätzen ermittelt. In erster Linie ist als Werkzeug gedacht, um Rasterwerte aus mehreren Datensätzen zu interpolieren. Typischer Anwendungsfall ist zB. das Tool zur Forstraßenableitung. Dieses wird auf Kachel-Basis erstellt und die Linienzüge werden zusammengeführt (merging). In der Folge sind linienabschnittsweise Attribute zu ermitteln (Fahrbahnbreite etc.). Dazu muss Kachel übergreifend interpoliert werden.

Eine weitere Überlegung sieht die Erweiterung auf Punktwolken als Input vor. dadürch würde opalsQuery zu einem universellen Tool, mit dem an beliebigen Stellen entweder Höhen, aber auch Attributwerte ermittelt werden können. Während im Rasterfall die Resampling-Methode vorgegeben werden muss (nearest neighbor, bilinear, bicubic) müsste bei den Punktwolken die Nachbarschaft definiert werden; am besten im bereits in Arbeit befindlichen Konzept zur allgemeinen Suche (über nn und/oder Suchradius).

Überlappungsbereich: Die Datensätze, welche die Interpolationsgrundlagen darstellen können sich überlappen. Daher muss geregelt werden, wie im Überlappungsbereich vorgegangen wird. Hier wurde das Konzept von Algebra über eine Formel zur Anwendung gebracht. Unterstützt wird die generische Filtersyntax (nicht Python). Zur Verfügung stehen damit alle statistischen Operatoren (first(r), min(r), mean(r), median(r), ...). Analog für den Punktwolken Fall: first(n.z), etc. Ich denke, das sollte ausreichende Möglichkeiten zur Steuerung bieten.

IO: Das derzeitige Konzept sieht opalsQuery als Dienstmodul vor, dass eher von Scripts benutzt, denn von der Kommandozeile ausgeführt wird. Demnach erfolgt die Eingabe der Geometrien, für die Höhen/Attribute ermittelt werden sollen, über WKT Strings (OGC Simple Features Specification) --> inGeometry. Ausgegeben wird die selbe Geometrie erweitert um die Z/Attribut Komponente (outGeometry). Vorteil: Via Python GDAL/OGR Bindings können die Geometrien direkt weiterverarbeitet werden. Nachteil Ein/Ausgabe als Files nicht möglich/vorgesehen. Diskussionsbeiträge dazu erwünscht.

Für die Abfrage von Werten auf Basis von Raster-Datensätzen

Parameter description

-inFileinput grid/odm files
Type: opals::Vector<opals::RasterFile>
Remarks: mandatory
The grid model files are expected in GDAL supported format. Vector files are expected in ODM data structure. The grid values of the respective models are referred to as r[0], r[1] ... in the calculation formula. The (neighbouring) ODM points are addressed via n[0], n[1] ...
RasterFile: File path of a raster dataset.
See Supported grid/raster formats
-inGeometryinput geometries in WKT syntax
Type: opals::Vector<opals::String>
Remarks: mandatory
The geometries are expected in OGC Well-Known-Text representation.
-outGeometryoutput geometries in WKT syntax
Type: opals::Vector<opals::String>
Remarks: output
The output geometries receive the interpolated values as Z- or M- component.
-formulaalgebraic formula for overlapping input datasets
Type: opals::String
Remarks: default=mean(r)
For each vertex position of an input geometry the respective (height/attribute) value is interpolated from all potential input data sets. In case that the value can be interpolated from multiple data sets, a formula in Generic Filter syntax can be provided giving, which controls the calculation of the final height attribute value. A formula must return a value (e.g. mean(r) or first(r)
-resamplinggrid resampling method.
Type: opals::ResamplingMethod
Remarks: default=bilinear
Possible values:  
  nearestNeighbour ... nearest neighbour
  bilinear ........... bi-linear interpolation
  bicubic ............ bi-cubic interpolation
Method to be used for interpolating grid values at the data point locations.
-maxMemorymaximum RAM memory [MB]
Type: uint32
Remarks: default=500
The memory consumption scales with the number of input grids in order to provide good reading performance. An upper memory limit can be specified in order to avoid overflows in case of numerous input grids (e.g. large mosaic),
-lineVertexDistline vertex spacing interval
Type: double
Remarks: optional
In case the input geometry (-inGeometry) represents a linear object (line string, polygon, etc.) additional vertices between two line nodes are calculated in regular intervals.

Examples


The data used in the subsequent examples are located in the $OPALS_ROOT/demo/ directory and the following preprocessing steps (data import and surface grid calculation) are required:

opalsImport -inFile strip21.laz
opalsGrid -inFile strip21.odm -outFile strip21_ne.tif -gridSize 1 -interpolation movingPlanes -limit "(529715 5338680 529860 5338770)"
opalsGrid -inFile strip21.odm -outFile strip21_nw.tif -gridSize 1 -interpolation movingPlanes -limit "(529570 5338680 529715 5338770)"
opalsGrid -inFile strip21.odm -outFile strip21_se.tif -gridSize 1 -interpolation movingPlanes -limit "(529715 5338590 529860 5338680)"
opalsGrid -inFile strip21.odm -outFile strip21_sw.tif -gridSize 1 -interpolation movingPlanes -limit "(529570 5338590 529715 5338680)"

With the above commands the entire domain of the strip21 dataset is split up in four quadrants, for each of which a separate surface model is calculated.

Example 1

In the following example a line geometry stored as WKT string satisfying the OGC Simple Feature Specification is processed and for each vertex of the line the corresponding heights are queried from the underlying surface grid models.

opalsQuery -inFile strip21_ne.tif strip21_nw.tif strip21_se.tif strip21_sw.tif -inGeometry "LINESTRING(529635 5338727, 529635 5338626, 529763 5338626, 529826 5338711)" -outParamFile outGeom.xml

Please note that each of the four line vertices are located in a different grid model. The vertex heights are automatically calculated from the appropriate grid model. The resulting 3D line geometry is stored in the outGeometry parameter (c.f. output parameter file outGeom.xml) as a WKT string:

LINESTRING (529635 5338727 270.45843505859375,529635 5338626 279.5660400390625,529763 5338626 272.25079345703125,529826 5338711 286.2608642578125)

Example 2

In the following example the parameter lineVertixDist is specified resulting in a densified output line string.

opalsQuery -inFile strip21_ne.tif strip21_nw.tif strip21_se.tif strip21_sw.tif -inGeometry "LINESTRING(529635 5338727, 529763 5338626, 529826 5338711)" -lineVertexDist 10 -outParamFile outGeom.xml

The following (3D) output line string is generated (coordinates rounded to 3 digits):

LINESTRING (529635.000 5338727.000 270.458, 529653.286 5338712.571 270.667, 529671.571 5338698.143 271.098, 529689.857 5338683.714276.881, 529708.143 5338669.286 271.812, 529726.429 5338654.857 274.894, 529744.714 5338640.429 283.058, 529763.000 5338626.000 272.251, 529775.600 5338643.000 279.833, 529788.200 5338660.000 272.246, 529800.800 5338677.000 285.582, 529813.400 5338694.000 278.098, 529826.000 5338711.000 286.261)

Example 3

opalsQuery is primarily designed as a utility module to be used in a scripting environment. As a Python script, example 1 can be written as:

1 import opals
2 from osgeo import ogr
3 from opals import Query
4 
5 qry = Query.Query()
6 qry.commons.screenLogLevel = opals.Types.LogLevel.error
7 qry.inFile = ["strip21_ne.tif","strip21_nw.tif","strip21_se.tif","strip21_sw.tif"]
8 qry.inGeometry = ["LINESTRING(529635 5338727, 529635 5338626, 529763 5338626, 529826 5338711)"]
9 qry.run()
10 outGeom = qry.outGeometry
11 line3d = ogr.CreateGeometryFromWkt(outGeom[0])
12 print("\nResulting 3D line geometry: {}".format(outGeom[0]))
13 print("\nEnvelope 2D: {}".format(line3d.GetEnvelope()))
14 print("\nEnvelope 3D: {}".format(line3d.GetEnvelope3D()))
15 print("\nLine length: {}".format(line3d.Length()))

In addition to the commandline example above the Python script not only prints out the resulting 3d-line WKT string but also creates an OGR line geometry object and prints the 2d envelope, 3d-envelope and line length. Please note, that the GDAL/OGR python bindings must be installed (c.f. OPALS Python AddOns ).

The command...

python queryDemo.py

... creates the following screen log.

[...]
Resulting 3D line geometry: LINESTRING (529635 5338727 270.45843505859375,529635 5338626 279.5660400390625,529763 5338626 272.25079345703125,529826 5338711 286.2608642578125)

Envelope 2D:  (529635.0, 529826.0, 5338626.0, 5338727.0)
Envelope 3D:  (529635.0, 529826.0, 5338626.0, 5338727.0, 270.45843505859375, 286.2608642578125)
Line length:  334.80170131

References

Author
gm
Date
01.03.2017
@ lineVertexDist
Regular distance for vertex spacing along linear geometries.
@ outParamFile
final parameter export
@ movingPlanes
moving (tilted) plane interpolation
opalsQuery is the executable file of Module Query
Definition: ModuleExecutables.hpp:168
opalsImport is the executable file of Module Import
Definition: ModuleExecutables.hpp:113
This is the fake namespace of all opals Python scripts.
Definition: __init__.py:1
@ inGeometry
input (OGC) gemeotry
opalsGrid is the executable file of Module Grid
Definition: ModuleExecutables.hpp:93