rotate and crop dataset
rotate and crop dataset
Dear Forum,
I recently started to work with point clouds from TLS - Data. I have a huge plot (over 1 hectar) of trees scanned. So it is a quite big dataset. To reduce the data I try to focus only to the area of interest (AOI). The data is geo-referenced and I do have the exact coordinates of my AOI. Basically I want to crop my point cloud to those coordinates.
My problem:
The only problem I encountered so far is that my plot isn't orthogonal to the coordinate-system. See picture one.
I solved this by using the Edit/Apply transformation (alt+t) and using the calculated correction angle (in this case ~12 degrees, see Picture two).
Now a have a rotated cloud, but it seems that the rotation was done around the center of the bounding shape (just guessing).
Because if I try to crop the cloud by my coordinates of my AOI, it wouldn't crop at the expected position.
In my use case it would be nice if it would rotate around my lower left corner so at least that coordinate wouldn't change.
My question:
Is it possible to
a) crop a point cloud with an polygonal shape to my exact coordinates of my plot or
b) to rotate the cloud and then somehow calculate the new relative position of my coordinates.
Do you have any suggestions to help me?
Best
Tobias
---------------------------
pictures: First one displays just two out of the 146 scans of the plot, but the plot size is displayed by the bounding box. In the middle u can see a quite straight line of rails were a crane is attached
The second one is the same as above but rotated ~12 degrees, now I want to crop the point cloud again. starting roughly there where the points in the lower left corner are visable (actually I need to crop a few meters to the right)
edit: sorry for the doubble post, I forgot to attach the pictures
I recently started to work with point clouds from TLS - Data. I have a huge plot (over 1 hectar) of trees scanned. So it is a quite big dataset. To reduce the data I try to focus only to the area of interest (AOI). The data is geo-referenced and I do have the exact coordinates of my AOI. Basically I want to crop my point cloud to those coordinates.
My problem:
The only problem I encountered so far is that my plot isn't orthogonal to the coordinate-system. See picture one.
I solved this by using the Edit/Apply transformation (alt+t) and using the calculated correction angle (in this case ~12 degrees, see Picture two).
Now a have a rotated cloud, but it seems that the rotation was done around the center of the bounding shape (just guessing).
Because if I try to crop the cloud by my coordinates of my AOI, it wouldn't crop at the expected position.
In my use case it would be nice if it would rotate around my lower left corner so at least that coordinate wouldn't change.
My question:
Is it possible to
a) crop a point cloud with an polygonal shape to my exact coordinates of my plot or
b) to rotate the cloud and then somehow calculate the new relative position of my coordinates.
Do you have any suggestions to help me?
Best
Tobias
---------------------------
pictures: First one displays just two out of the 146 scans of the plot, but the plot size is displayed by the bounding box. In the middle u can see a quite straight line of rails were a crane is attached
The second one is the same as above but rotated ~12 degrees, now I want to crop the point cloud again. starting roughly there where the points in the lower left corner are visable (actually I need to crop a few meters to the right)
edit: sorry for the doubble post, I forgot to attach the pictures
- Attachments
-
- 02_Rotated.jpeg (128.31 KiB) Viewed 9811 times
-
- 01_original.jpeg (137.31 KiB) Viewed 9811 times
Re: rotate and crop dataset
First, the 'Apply Transformation' tool applies the rotation around the coordinate system origin (P' = R.P + T - where R is the rotation matrix, and T the translation). But whatever the way you apply the rotation, your (X,Y) coordinates will change (even slightly), won't they?
I guess the AOI coordinates are in the 'real world' coordinate system? And your cloud hasn't been registered yet? The only proper solution to handle this would be to 'align' your cloud with Ground Control Points (at least 3) so that the TLS point cloud ends at the right position... or did I miss something?
I guess the AOI coordinates are in the 'real world' coordinate system? And your cloud hasn't been registered yet? The only proper solution to handle this would be to 'align' your cloud with Ground Control Points (at least 3) so that the TLS point cloud ends at the right position... or did I miss something?
Daniel, CloudCompare admin
Re: rotate and crop dataset
Dear Daniel,
thank you for your quick reply, it seems I missed it, I'm sorry for the long delay.
The data I have is georeferenced, and to my knwoledge there were used seven ground control points used during the 146 scans of the entire plot. So I guess my AOI is in a real world coordinate system. But CloudCompare did a translation (global shift) before opening the file, because my x and y values are pretty big.
Since the global shift is stored and restored at export time, I'm okay with this.
If the rotation is around the coordinate system origin as you explained it I should be able to calculate the new coordinates with some vector calculations.. I have to look it up this week how to do so, but something I learned long time ago in school might help :).
The problem I might have, is that the automatic translation did not set my point cloud to the origin of the coordinate system.
The original x is 312657.279175 and is translated into 57.27917 and y is translated from 5693918.939423 to 18.93942.
I guess if I set the shift of x and y both to 0, my point cloud would be at the origin, right?
Starting from there I should be able to rotate my cloud, then crop it further to reduce it more precisely to my AOI and then rotate it back so I have again a georeferenced cloud.
I'm going to test this and report back :)
Again, thank you for your answer.
Best Tobias
thank you for your quick reply, it seems I missed it, I'm sorry for the long delay.
The data I have is georeferenced, and to my knwoledge there were used seven ground control points used during the 146 scans of the entire plot. So I guess my AOI is in a real world coordinate system. But CloudCompare did a translation (global shift) before opening the file, because my x and y values are pretty big.
Since the global shift is stored and restored at export time, I'm okay with this.
If the rotation is around the coordinate system origin as you explained it I should be able to calculate the new coordinates with some vector calculations.. I have to look it up this week how to do so, but something I learned long time ago in school might help :).
The problem I might have, is that the automatic translation did not set my point cloud to the origin of the coordinate system.
The original x is 312657.279175 and is translated into 57.27917 and y is translated from 5693918.939423 to 18.93942.
I guess if I set the shift of x and y both to 0, my point cloud would be at the origin, right?
Starting from there I should be able to rotate my cloud, then crop it further to reduce it more precisely to my AOI and then rotate it back so I have again a georeferenced cloud.
I'm going to test this and report back :)
Again, thank you for your answer.
Best Tobias
Re: rotate and crop dataset
The problem is that if you don't shift the cloud (setting the shift to (0,0) then you'll lose accuracy!
You should better consider using your new origin (the 'original' cloud origin minus the global shift, i.e. (57.27917, 18.93942) if I understood well). Sorry for the additional arithmetic, but that's the only mechanism in CC to preserve large coordinates accuracy.
You should better consider using your new origin (the 'original' cloud origin minus the global shift, i.e. (57.27917, 18.93942) if I understood well). Sorry for the additional arithmetic, but that's the only mechanism in CC to preserve large coordinates accuracy.
Daniel, CloudCompare admin
Re: rotate and crop dataset
Very well Daniel,
I'm going to set my point cloud manually to the origin and rotate it.
Since the translation is reversed after export I"m okay with the additional arithmetic's.
The hard job is going to be to isolate all the trees of this point cloud into separate objects/point clouds, but I managed to find a software "CompuTree" which is designed to deal with such kind of tasks.
Thank you for your help and really quick replies, you are doing a great job in this forum and with your program!
Best Tobias
I'm going to set my point cloud manually to the origin and rotate it.
Since the translation is reversed after export I"m okay with the additional arithmetic's.
The hard job is going to be to isolate all the trees of this point cloud into separate objects/point clouds, but I managed to find a software "CompuTree" which is designed to deal with such kind of tasks.
Thank you for your help and really quick replies, you are doing a great job in this forum and with your program!
Best Tobias
Re: rotate and crop dataset
It seems that I'm failing to get my point cloud to the origin of the coordinate system with CloudCompare. It seems there is a quite big shift after rotation of the cloud. So my guess is that my cloud is not set correctly to the origin.
The first thing I do is to import the pount cloud and apply the automatoíc global shift. After that, my point cloud is not at the origin. Hence that, I open the " edit global shift and scale" function again and insert the presumably excact coordinates. Basically I add 57.27917, 18.93942) and hence the cloud should be at the origin. But it seems that it isn't doing that.
Am I doing something wrong? Or do you have an idea what I can do to fix this?
Best Tobias
The first thing I do is to import the pount cloud and apply the automatoíc global shift. After that, my point cloud is not at the origin. Hence that, I open the " edit global shift and scale" function again and insert the presumably excact coordinates. Basically I add 57.27917, 18.93942) and hence the cloud should be at the origin. But it seems that it isn't doing that.
Am I doing something wrong? Or do you have an idea what I can do to fix this?
Best Tobias
Re: rotate and crop dataset
Once loaded, you can't shift the cloud with the 'Global shift' information (it's meant to be used only at loading and saving time).
Either you set the right shift at loading time (in the Global Shift dialog that automatically appears). Or more simply you apply the remaining shift afterwards with 'Edit > Apply transformation'.
Either you set the right shift at loading time (in the Global Shift dialog that automatically appears). Or more simply you apply the remaining shift afterwards with 'Edit > Apply transformation'.
Daniel, CloudCompare admin
Re: rotate and crop dataset
Okay using the Apply transformation did the trick...
But on the way home I was wondering if it would be possible to crop my data set based on a polygon. First I started to write a simple java program which iterates through my file and only those point which are inside of the polygon are kept.
Then it occurred to me that this might be possible to do in CloudCompare as well.
I found the following in the documentation:
http://www.cloudcompare.org/doc/wiki/in ... _line_mode
I guess I can use this to simply crop my cloud at my area of interest coordinates. So all the rotation and cropping and so on is obsolet. Hopefully.command_line_mode wrote: -CROP2D {ortho_dim} {n:number of vertices} X1 Y1 X2 Y2 ... Xn Yn
I'll report back with the result :)
Best Tobias
Re: rotate and crop dataset
This is the code I used for the command line tool
open CMD and change directory to cloudcompare / shift right click on CloudCompare folder and open CMD there
Some explanations of the code since I had quite a bit of struggle to figure out the right syntax for it:
//open a file
//since data is georeferenced it needs to be globaly shiftet, I use specific values because I need to calculate the verticies of my polygon with those values [x y z]
//filename (I put my cloud into the folder of cloud compare but it would work as well with a given path to file), it seems like 'bin' files are processed much faster
//initialize the polygon crop functionality
// this is the crop direction {ortho_dim} in my case I cropped along the z axis
//how many vertices I want to use. In my case I used a rectangular shape but more complex shapes are possible
//my vertices coordinates I calculated, starting with x1 y2, x2, y2 ... xn, yn
now I'm trying to develop a for loop to loop through a folder with my 146 scans.
and again thanks Daniel! Great Software :)
Best Tobias
edit [forgot to append the loop]:
- open CMD were your files are or replace (./*) with path to files
- for [%f] means: for every file - whereas %f is a variable passed after -GLOBAL_SHIFT x y z [%f]
waits until cloudcompare exits and then starts the new crop
open CMD and change directory to cloudcompare / shift right click on CloudCompare folder and open CMD there
Code: Select all
CloudCompare -o -GLOBAL_SHIFT -312600 -5693000 0 merged_Full.asc -CROP2D z 4 46 829 77 1037 169 1027 122 849
//open a file
Code: Select all
CloudCompare -0
Code: Select all
GLOBAL_SHIFT -312600 -5693000 0
Code: Select all
merged_Full.asc
Code: Select all
-CROP2D
Code: Select all
z
Code: Select all
4
Code: Select all
46 829 77 1037 169 1027 122 849
and again thanks Daniel! Great Software :)
Best Tobias
edit [forgot to append the loop]:
Code: Select all
for %f in (./*) do start /w "" "C:\Program Files\CloudCompare\CloudCompare.exe" -SILENT -O -GLOBAL_SHIFT x y z %f -CROP2D z 4 x1 y1 x2 y2 x3 y3 x4 y4
- for [%f] means: for every file - whereas %f is a variable passed after -GLOBAL_SHIFT x y z [%f]
Code: Select all
start /w ""
Last edited by TMC on Fri Apr 05, 2019 1:08 pm, edited 1 time in total.