Monday, February 19, 2018

WebApp for calculating the 4x4 transformation matrix between 2 corresponding sets of 3D points

In working with 3D point clouds, one of the task may be to register or transform the point cloud to known ground control points (GCPs) on the ground with corresponding control points in the point cloud. For instance, the screen shot below shows the point cloud with four control points p1, p2, p3, and p4.

Note: At least 3 corresponding set of points are needed to calculate a rigid transformation matrix.

From the point cloud, the from-control points can be measured:

On the ground, the actual ground control points can be obtained, perhaps from a GPS receiver:


With the measured points from the point cloud and the corresponding control points on the ground, a 4x4 homogeneous transformation matrix can be calculated and used to rigidly transform the point cloud to the actual ground coordinate system. 

This WebApp calculator at https://dominoc925-pages.appspot.com/webapp/calc_transf3d/default.html can be used to calculate the 4x4 transformation matrix, as well as the root mean square error (RMSE) as an indicator of the quality of the control points i.e. the smaller the RMSE, the better they are. The WebApp uses the Numeric Javascript matrix library from http://www.numericjs.com/ for performing the required SVD decomposition to calculate the transformation matrix. Note that the library has some unfixed bugs in the SVD decomposition for certain cases and I may probably replace this with an alternative solution in future.  
  1. Paste the "from control points" into the Source Points text area field. 

  2. Paste the ground control point values into the Destination Points text area field.
  3. Click the Calculate button.



    The resultant transformation matrix appears in the 4x4 Transformation Matrix field. The RMSE for the calculation is displayed in the RMSE field.

Monday, February 12, 2018

Displaying WKT geometry string in QGIS with getWKT plugin

If you want to display the Well Known Text (WKT) string of a selected geometry in QGIS, there is a plug-in getWKT that can be used for this purpose. The screen shot below shows the Plug-in Manager's description of the getWKT plug-in.
 
 To use the getWKT plug-in, do the following:
  1. In QGIS, click the Select Features by area of single click button. Using the mouse, click on a feature.

    A feature is selected and highlighted in yellow.
  2. Then click the getWKT icon in the tool bar.



    The GetWKT dialog box appears with the WKT string of the selected geometry.

Monday, February 5, 2018

Find the 3x3 transformation matrix given a set of 3D points using Octave

I have 2 corresponding pair of 3 measured 3D points - one original coordinates (let's call as X) and the other destination or reference coordinates (say Y) . I wanted to find the transformation matrix (say A) that can transform the original coordinates to the destination coordinates.

Octave (an open source software alternative to Matlab. See https://www.gnu.org/software/octave/) has the tools to determine the 3x3 transformation matrix. This post shows how to perform the calculation.

Given the 3 original measured 3D points X:
x1 = (2, -1, 2)
x2 = (-1, 2, 2)
x3 = (2, 2, -1)

And the 3 measured destination 3D points Y:
y1 = (-2, -9, -30)
y2 = (-23, 12, 9)
y3 = (13, 6, -6)

  1. First, write out the transformation and coordinates in the following form

    AX=Y

    where A is the unknown transformation matrix,
    X is a matrix of the original coordinates formed by concatenating the points as column vectors X = [x1, x2, x3]
    Y is a matrix of the destination coordinates formed by concatenating the points as column vectors Y = [y1, y2, y3]
  2. Run Octave. In the command prompt, enter the X matrix values:

    $> X = [2 -1 2; -1 2 2; 2 2 -1]
  3. In the prompt, enter the Y matrix values:

    $> Y = [-2 -23 13; -9 12 6; -30 9 -6]
  4. Now calculate the inverse of X by typing the following into the prompt.

    $> IX = inv(X)
  5. The transformation matrix A can be calculated by simply multiplying the matrix Y with the inverse of X. Type in the following at the prompt:

    $> A = Y * IX
  6. Optional. Use the calculated matrix A and multiply with the original coordinates X and check whether the resultant values matches the measured Y coordinates.

Monday, January 29, 2018

Display CSV (with WKT geometry field) files on Google Maps with this Mapplet

If you want to display a Comma Separated Values (CSV) file with an embedded geometry field in Well Known Text (WKT) format with just an Internet browser, then this Mapplet may be useful to you. Just go to this url https://dominoc925-pages.appspot.com/mapplets/vcsvfile.html with any modern browser such as Chrome, or FireFox. All the processing is done within your browser, that is the CSV file is never uploaded to a server for processing.


  1. To load a CSV file, click on the Import CSV button (in blue color) as shown in the screenshot below. 



    The Import Comma Separated Values (CSV) file dialog box appears.

  2. To load in a CSV file from a local drive, click the Choose File button. Then browse and select a CSV file as shown below.



    Note: You can also copy and paste WKT text into the CSV file field's text area. Or click the Use Sample Data drop up button to load demo WKT data into the text area.

  3. Click Open.

    The file is read and displayed in the text area below the Choose File button. The WKT Geometry column button is populated with the header fields from the CSV file.


    Note: If necessary, choose an appropriate Coordinate System and projection.
  4. Click Start Import.

    The CSV file is loaded and rendered as overlays on the Google Maps backdrop. The name of the file is added to a CSV files combo box.

  5. Optional. Click on the CSV Command drop up button and choose a command to apply to the current CSV layer.


    Fit - Display the current CSV layer within the map
    Fit All - Display all loaded CSV layers within the map
    Toggle display - Toggle the CSV layer display on or off
    Display off - Don't display the current CSV layer
    Display on - Display the current CSV layer
    Remove layer - Unload the current CSV layer

Monday, January 22, 2018

Using QGIS to export CSV files with Well Known Text geometry

QGIS can export feature layers as comma separated values (*.CSV) files with a geometry column in  Well Known Text (WKT) format. This can be very convenient if you want to exchange a small amount of data from one GIS system to another GIS system.

To save a vector feature layer to a WKT CSV file, do the following:

  1. In the legend pane of QGIS, select a layer to export, e.g. forest. Then press the right click of the mouse.

    A pop up menu appears.

  2. In the pop up menu, choose Save As.
  3. The Save vector layer as dialog box appears.


  4. In the Format combo box, choose Comma Separated Values (CSV). In the File name field, click the  Browse button and type in the output file name, e.g. forest.csv.


  5. In the Layer Options group box's GEOMETRY combo box, choose AS_WKT. Click OK.

    The selected vector layer is exported out as a CSV file with a geometry field as WKT format as shown below in a spread sheet.

Monday, January 15, 2018

displaz - A small but fast LiDAR las file viewer

I'm happy with this LiDAR las file viewer displaz I stumbled upon while doing some searching on Google. It's free, open-source, no-frills, fast, and relatively easy to use - just perfect to drag and drop some las files for a quick look. It can be downloaded from this web site http://c42f.github.io/displaz/.

The following are some sample screenshots of the viewer.
  1. Upon start up, the viewer shows a blank view with a shader parameters and Log or Datasets panes on the right.



    Note: The points are colored according to intensity values. This can be changed by choosing an alternative coloring method in the Shader parameters pane
    .
  2. Las files and be opened by simply dragging it(them) and dropping onto the application window from the operating system's file managers.


    Note: once opened, the file(s) are listed in the Datasets pane. To view the point cloud from a different orientation, drag and move the mouse left button. To zoom, roll the mouse wheel.
  3. This is a little confusing at first, but to pan or move the view, you have to press the middle button of the mouse to center the view around the chosen point. At the same time, it will show the attributes of the chosen point in the Log pane, as shown below.


  4. Finally, to unload a las file, select one or more files in the Datasets pane and press the DELETE button on the keyboard.



Monday, January 8, 2018

Getting FugroViewer to run in Ubuntu 16.04

I wanted to try running the free but not open source Lidar viewer from Fugro on Ubuntu. FugroViewer can be downloaded from https://www.fugro.com/about-fugro/our-expertise/technology/fugroviewer.

Since FugroViewer is a Windows only application, I had to use Wine to install and run it. I was successful in getting it to run and the following steps illustrate how to set up, install and run FugroViewer on Ubuntu.

Install Wine

  1. In Ubuntu, open up a terminal.
  2. At the command prompt, type in the following command to download a key. Press RETURN.

    $ wget https://dl.winehq.org/wine-builds/Release.key

    The file Release.key is downloaded.

  3. Next, add the key to Ubuntu. Type in the admin password when prompted.

    $ sudo apt-key add Release.key


  4. Now add in the Wine repository to Ubuntu by entering the following command:

    $ sudo apt-add-repository 'https://dl.winehq.org/wine-builds/ubuntu/'


  5. At the command prompt, type in the command:

    $ sudo apt-get update

  6. Finally, install Wine with the following command.

    $ sudo apt-get install wine


Install FugroViewer

Once Wine is installed, it can be used to run the FugroViewer installer (which must be downloaded from the Fugro web site https://www.fugro.com/about-fugro/our-expertise/technology/fugroviewer previously).

  1.  Using a File Manager in Ubuntu, browse to the location of the downloaded FugroViewer installer. Double click on the file or press mouse right click and choose Open with Wine Windows Program.


    The Fugro Viewer Setup wizard appears.
  2. Complete the installation by following the Fugro Viewer Setup wizard.


Running FugroViewer
  1. On the desktop, click the Dash button on the top right. Then type in fugro.

    The FugroViewer application icon is shown.

  2. Click on the FugroViewer icon.

    The FugroViewer application starts up.
  3. Now load in one or more LAS files.

    The LAS file is displayed.
Related Posts with Thumbnails