Skip to main content

I have 3D polygons where I need to calculate the aspect for each polygon and add it as attribute. Is there a way to do this? I found a transformer to calculate the aspect for raster but not for vector ,is there a way to go around? Thanks !

Hi @irene2018,

You can use the FaceReplacer to convert the 3D polygon to a face, then use the PlanarityFilter to get the normal for the surface. The X and Y components of the surface normal can be used in the atan2 arithmetic function to calculate the aspect angle of the surface.

This will be a cartesian angle (CCW, 0 at horizontal), so you may need to convert this to a compass bearing (CW, 0 at vertical).


thanks a lot! I will try this


Hi @irene2018,

You can use the FaceReplacer to convert the 3D polygon to a face, then use the PlanarityFilter to get the normal for the surface. The X and Y components of the surface normal can be used in the atan2 arithmetic function to calculate the aspect angle of the surface.

This will be a cartesian angle (CCW, 0 at horizontal), so you may need to convert this to a compass bearing (CW, 0 at vertical).

Hi @DaveAtSafe would you mind elaborating on how to transform the result of the atan2 function from cartesian angle to a compass bearing?

I am currently using the atan2 function in a ExpressionEvaluator transformer as follow:

@atan2(@Value(_surfaceNormalX),@Value(_surfaceNormalY))

This after calculating the surface normals (X and Y) via the PlanarityFilter transformer.


Hi @DaveAtSafe would you mind elaborating on how to transform the result of the atan2 function from cartesian angle to a compass bearing?

I am currently using the atan2 function in a ExpressionEvaluator transformer as follow:

@atan2(@Value(_surfaceNormalX),@Value(_surfaceNormalY))

This after calculating the surface normals (X and Y) via the PlanarityFilter transformer.

Hi @itay,

To convert from cartesian to a compass bearing (or vice versa), you can use fmod((450 - angle), 360).

However, the result of atan2 is usually radians, so you will need to multiply that by 180/pi first to get degrees.


Hi @itay,

To convert from cartesian to a compass bearing (or vice versa), you can use fmod((450 - angle), 360).

However, the result of atan2 is usually radians, so you will need to multiply that by 180/pi first to get degrees.

Thx @DaveAtSafe


would you please explain how to use the PlanarityFilter to get the normal for the surface.


Hi @irene2018,

If you open the properties of the PlanarityFilter, there is a setting at the bottom to calculate the surface normal:

The surface normal will be supplied in three new attributes:

_surfaceNormalX

_surfaceNormalY

_surfaceNormalZ


@DaveAtSafe thanks! and if I want to calculate aslo the inclination of each polygon ,What should I do?


Hi @irene2018,

The inverse cos (acos) of the Z component should give you your inclination off the horizontal.


@DaveAtSafe the z component is the _Zsurface normal?


@DaveAtSafe the z component is the _Zsurface normal?

Hi @irene2018,

Yes.


@DaveAtSafe the z component is the _Zsurface normal?

@ Dave At Safe, thanks for your clear answer! . Does this also need to be converted to a compass bearing and then multiply that by 180/pi to get degrees?

 


@ Dave At Safe, thanks for your clear answer! . Does this also need to be converted to a compass bearing and then multiply that by 180/pi to get degrees?

 

Hi @irene2018,

It doesn't need to be converted to a compass bearing, but the result will be in radians, so you do need to multiply it by 108/pi to get degrees.


Hi@DaveAtSafe , I have problem with face replacer transformer ,as not all polygons are planar ,I passed by geometry validater transformer that has corrected the problem but the type of polygons has changed to "FME_aggreate" so the face replacer doesn't work ,is there a solution for that?Thanks!


Hi@DaveAtSafe , I have problem with face replacer transformer ,as not all polygons are planar ,I passed by geometry validater transformer that has corrected the problem but the type of polygons has changed to "FME_aggreate" so the face replacer doesn't work ,is there a solution for that?Thanks!

Hi @irene2018,

Try setting the Thickness Mode on the FaceReplacer to Ignore. This will skip the planarity check. You may also want to set the Angular Mode to ignore as well.


Hi @irene2018,

It doesn't need to be converted to a compass bearing, but the result will be in radians, so you do need to multiply it by 108/pi to get degrees.

Thanks @ Dave At Safe ,I was able to calculate but the inclination of flat roof should be between 0 to 15 degrees and I have 80 so i missed something. I calculate the z normal and then do acos (z normal component *57.295


Thanks @ Dave At Safe ,I was able to calculate but the inclination of flat roof should be between 0 to 15 degrees and I have 80 so i missed something. I calculate the z normal and then do acos (z normal component *57.295

Hi @irene2018,

Please move the '*57.295' outside of the acos() expression.


Hi @irene2018,

Please move the '*57.295' outside of the acos() expression.

Hi@ Dave At Safe ,the result is not logic ,the pitched roofs have an inclination of 2.5 degrees while flat roof has 3 degrees ,i can send you the vector file if needed


Reply