I have 3D point cloud (laser scanning) and an orthophoto, geo-referenced by a TIFF World File (.tfw). I want to project every 3D point of the point cloud into the 2D image.

Here is an example of a .TFW file:


These are the 6 coefficients of a three-by-three transformation matrix. They indicate that a pixel is 2.4384 meters square, and that the center of the upper left pixel has an easting (x coordinate) of 441794.4342 and a northing of 5094101.4520. See here.

So I can get the X,Y of the point cloud (supposing that the Z is 0):

x_cloud = 2.4384 * column + 0.0 * row + 441794.4342
y_cloud = (-2.4384) * row + 0.0 * column + 5094101.4520

How do I find (X_pixel, Y_pixel) from a 3D point using the TFW file?


I found a solution for my problem, it was simple. let's see our TIFF World File

2.4384 -> A
0.0000 -> B
0.0000 -> C
-2.4384 -> D
441794.4342 -> E
5094101.4520 ->F

here is my pseudo code:

forEach point cloud  {

    x_cloud = currentX_cloud;
    y_cloud = currentY_cloud;
    z_cloud = currentZ_cloud;

    x_pixel = (x_cloud - E) / A;
    y_pixel = img.rows - (y_cloud - F + A * img.rows) / A;

//accessing to pixel values

    R = img.at<cv::Vec3b>(y_pixel, x_pixel)[0];
    G = img.at<cv::Vec3b>(y_pixel, x_pixel)[1];
    B = img.at<cv::Vec3b>(y_pixel, x_pixel)[2];


(I'm using OpenCV to manipulate the orthophoto and LidarFormat to deal with the point cloud data (LAS file))

closed as off-topic by Andre Silva, whyzar, PolyGeo Aug 6 '17 at 0:32

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – Andre Silva, whyzar, PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • This will require some coding and/or software. What do you have skills/knowledge of? – Barbarossa Aug 4 '17 at 14:32
  • Yes I'm working with C++. I'm using this library to manipulate my point cloud and OpenCV to deal with the TIFF image. – Namouchi Aug 4 '17 at 14:37
  • Do you want to 'add' the z values (or other attribute from the point cloud) from every LiDAR return in the point cloud to the corresponding pixel at the orthophoto? What do you mean by 'x_cloud' and 'y_cloud'? Those are how one gets the central coordinates of pixels in the orthophoto. The 'x' and 'y' coordinates from LiDAR points are stored in the .las files, aren't they? Why the name 'cloud', then?. And what do you mean with X_pixel and Y_pixel? The corresponding pixel from the orthophoto the LiDAR point falls within (coming back to my first question)? – Andre Silva Aug 5 '17 at 23:00
  • If it is what I said in my first and last question from previous comment, how do you plan to carry on if there are more than one LiDAR point inside the same pixel in the orthophoto? Or could you clarify, if I did not understand your question? Thanks. – Andre Silva Aug 5 '17 at 23:01
  • Also, if I understood correctly your question, please explain and detail (by editing the question) how it is different from previous questions: gis.stackexchange.com/questions/138611/… (R); gis.stackexchange.com/questions/229754/… (FME); gis.stackexchange.com/questions/232021/… (ArcGIS). – Andre Silva Aug 5 '17 at 23:08

PDAL supports this with by using GDAL with the filters.colorization Filter. GDAL handles all the geo transformation math, and both PDAL and GDAL handle the format silliness for you. You can find an example PDAL pipeline that applies the operation in the PDAL workshop example.


Not the answer you're looking for? Browse other questions tagged or ask your own question.