Skip to main content
Solved

Rounding IFMEPointCloud XYZ components


Hello everyone,

 

I am trying to round the x, y and z components of Pointclouds to a precision of 3. I have tried the coordinaterounder but as is already stated in the Coordinaterounder documentation (http://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Transformers/Transformers/coordinaterounder.htm) the behaviour of this transformer can be erratic. For some points I get far more then 3 decimal places, while for others it is rounded to an integer. I have also tried the Pointcloudexpressionevaluator as in this solution (https://community.safe.com/s/question/0D54Q00009HJ87MSAT/rounding-ifmepointcloud-xyz-components-with-pythoncaller) but this also does not seem to work for my data.

 

Is there another option I could try or is there maybe something I might be missing from the previous solution?

 

Thank you in advance!

 

Best answer by evieatsafe

yasminvb wrote:

Hello,

Thank you for this solution. It seems to do the trick when I click on particular points I get a precision of 3 (=dp). So the transformation seems to go correct now. However, when I write the pointcloud to .xyz (pointcloud xyz writer) the precision of 3 is not kept. I set the "point cloud file definition" to automatic.

Hi @yasminvb​ thanks for your question. By talking with a colleague I believe there is a workaround as we currently do not support this in our xyz writer.

  • You could convert the points to features using a PointCloudToPointCoercer transformer, format the attributes with a StringFormatter transformer, then write the features out with a CSV writer.
  • View attached workspace, bookmark #3

 

More information on how FME handles this:

The CoordinateRounder (or PointCloudExpressionEvaluator) will round coordinates to the specified precision, but the coordinates are still stored as floating point values, not strings. For example, a value displayed as "1.234" might actually be stored as 1.2339999999999999857891452848. The PointCloudXYZ writer will convert those floating point values to strings and write them to the output file. This float-to-string conversion will generally only include "meaningful" precision (e.g. you should get "1.234" instead of "1.2339999999999999857891452848"), so this should hopefully be most of the way to what is wanted. A caveat to that would be if the user wants a specific number of digits of precision all the time, even if the number could be represented with fewer digits, e.g. you want "1.000" instead of "1". Currently we don't offer tools to do that with point clouds.

View original
Did this help you find an answer to your question?

3 replies

hkingsbury
Celebrity
Forum|alt.badge.img+55
  • Celebrity
  • December 5, 2022

Hmm, its weird that the @Round() function doesn't work in the pointcloudexpression evaluator. Either way, here is some code that should round correctly :)

 

 

@if(
     @fmod((@Component(num)*(@pow(10,@Value(dp))*10)),10)>=5,
    @Ceil(@Component(num)*@pow(10,@Value(dp)))/@pow(10,@Value(dp)),
    @Floor(@Component(num)*@pow(10,@Value(dp)))/@pow(10,@Value(dp))
    )

 

Just make sure there is an attribute on the feature (not a component) that has the number of decimal places to round to


  • Author
  • December 12, 2022

Hello,

Thank you for this solution. It seems to do the trick when I click on particular points I get a precision of 3 (=dp). So the transformation seems to go correct now. However, when I write the pointcloud to .xyz (pointcloud xyz writer) the precision of 3 is not kept. I set the "point cloud file definition" to automatic.


evieatsafe
Safer
  • Safer
  • Best Answer
  • December 15, 2022
yasminvb wrote:

Hello,

Thank you for this solution. It seems to do the trick when I click on particular points I get a precision of 3 (=dp). So the transformation seems to go correct now. However, when I write the pointcloud to .xyz (pointcloud xyz writer) the precision of 3 is not kept. I set the "point cloud file definition" to automatic.

Hi @yasminvb​ thanks for your question. By talking with a colleague I believe there is a workaround as we currently do not support this in our xyz writer.

  • You could convert the points to features using a PointCloudToPointCoercer transformer, format the attributes with a StringFormatter transformer, then write the features out with a CSV writer.
  • View attached workspace, bookmark #3

 

More information on how FME handles this:

The CoordinateRounder (or PointCloudExpressionEvaluator) will round coordinates to the specified precision, but the coordinates are still stored as floating point values, not strings. For example, a value displayed as "1.234" might actually be stored as 1.2339999999999999857891452848. The PointCloudXYZ writer will convert those floating point values to strings and write them to the output file. This float-to-string conversion will generally only include "meaningful" precision (e.g. you should get "1.234" instead of "1.2339999999999999857891452848"), so this should hopefully be most of the way to what is wanted. A caveat to that would be if the user wants a specific number of digits of precision all the time, even if the number could be represented with fewer digits, e.g. you want "1.000" instead of "1". Currently we don't offer tools to do that with point clouds.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings