Skip to main content
Question

Dynamic buffer size from polygon


raabster
Contributor
Forum|alt.badge.img+4

Hi all!

I have a polygon where every vertex/point (don’t know the correct termonology) has a xyz coordinate. I would like to create a buffer where the buffer size depends on the z-coordinate. Couldn’t figure it out how to do it. Anyone who can help me figure this out?

18 replies

nielsgerrits
VIP
Forum|alt.badge.img+54

Not sure if I understand what you want. If you want to convert the polygon to points and then buffer the points by z value steps are:

  • Chopper to get individual points from polygon.
  • CoordinateExtractor to get _z from points.
  • Bufferer to buffer points. Choose _z for Buffer Distance.

If the points need to be connected back into one geometry, you can use the HullAccumulator to do this.


raabster
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • February 26, 2024

Thank you for your swift reply :)

To clarify, let’s say that I have this shape, called “base shape”:

“base shape”

If I use the bufferer transformer and set it to, say -10 meters, I get the orange line:

“base shape”+”constant buffer”

What I’m looking for, is to use the z-value at each “point” to get the green line:

“base”+”constant”+”desired buffer”

 

Hope that sheds some light at what I’m looking for. I’ll try your solution and see what that gives me, thank you once again :)


nielsgerrits
VIP
Forum|alt.badge.img+54

Thanks, a drawing like this always helps understanding the question :)


joepk
Influencer
Forum|alt.badge.img+20
  • Influencer
  • February 26, 2024

Hello, what an interesting question. The drawing helps a lot! I think we want to extract all vertices, calculate a centerpoint (using a CenterPointReplacer) and move all vertices distance z towards the centerpoint. Then we can rebuild the polygon using an AreaBuilder.

Moving the coordinates z meters towards the centerpoint is going to be the hard part. Is your coordinate system in meters?


nielsgerrits
VIP
Forum|alt.badge.img+54
joepk wrote:

Hello, what an interesting question. The drawing helps a lot! I think we want to extract all vertices, calculate a centerpoint (using a CenterPointReplacer) and move all vertices distance z towards the centerpoint. Then we can rebuild the polygon using an AreaBuilder.

Moving the coordinates z meters towards the centerpoint is going to be the hard part. Is your coordinate system in meters?

I think this can be done using a Scaler? Or OffsetCurveGenerator.


joepk
Influencer
Forum|alt.badge.img+20
  • Influencer
  • February 26, 2024

  

nielsgerrits wrote:

I think this can be done using a Scaler? Or OffsetCurveGenerator.

I don't see any options in either the Scaler nor the OffsetCurveGenerator that allow for vertex-precise scaling of polygons. But I am using 2019.1, so I could be missing some functionality there. 
I was thinking of something like this:

And then use the _angle attribute from the NeighborFinder combined with the z attribute to figure out the new x and y coordinates of each vertex. Then stitch it all back together using an AreaBuilder. 

But if the Scaler route works, that is probably more viable. 


nielsgerrits
VIP
Forum|alt.badge.img+54

This is how I solved it:

  • Geometry to attribute.
  • Explode polygon to points.
  • Extract Z from points.
  • Generate vertex id’s.
  • Restore polygon from attribute.
  • Offset polygon based on Z.
  • Explode polygons to points.
  • Merge both sets of points so you have the corresponding vertice id and z value.
  • Create polygon from points.

raabster
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • February 26, 2024
joepk wrote:

Moving the coordinates z meters towards the centerpoint is going to be the hard part. Is your coordinate system in meters?

Yes it is


raabster
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • February 26, 2024
nielsgerrits wrote:

This is how I solved it:

  • Geometry to attribute.
  • Explode polygon to points.
  • Extract Z from points.
  • Generate vertex id’s.
  • Restore polygon from attribute.
  • Offset polygon based on Z.
  • Explode polygons to points.
  • Merge both sets of points so you have the corresponding vertice id and z value.
  • Create polygon from points.

Wow, what a solution :)

Although when I run it with my own data I run in to this error message:

OffsetCurveGenerator_offsetter (TeeFactory): OffsetCurveGenerator_offsetter: @Buffer2 -- Parameter 'Buffer2' must be a floating point number -- 'BufferWidth' is not valid

Tester_FAILED_-1_84_Player (RecorderFactory): OffsetCurveGenerator_offsetter: @Buffer2 -- Parameter 'Buffer2' must be a floating point number -- 'BufferWidth' is not valid

 

Any idea what is happening there? Upon further inspection the flow doesn’t seem to behave correctly before this error message occurs. If you feel like it, please see attached file for the areas I’m working on.


raabster
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • February 26, 2024

If you do look at the data, you can try to use a buffer size of say 5% of the z-value of each vertex as an example. Or whatevery you feel like :)


joepk
Influencer
Forum|alt.badge.img+20
  • Influencer
  • February 26, 2024

I also managed to complete my workflow. I calculated the new coordinates of each vertex using these formulas:

x_moved = x + z * cos(degToRad(angle))
y_moved = y + z * sin(degToRad(angle))

Haven't done anything this close to high school trigonometry in quite a while, so I might have made a little error somewhere, please be mindful of this 😊

 

Have a nice day!


nielsgerrits
VIP
Forum|alt.badge.img+54

The shapes you attached are 2D, so it is missing the 3rd coordinate you wanted to use to shift the points :)

 

I think @joepk his idea is better than mine.


nielsgerrits
VIP
Forum|alt.badge.img+54
joepk wrote:

I also managed to complete my workflow. I calculated the new coordinates of each vertex using these formulas:

x_moved = x + z * cos(degToRad(angle))
y_moved = y + z * sin(degToRad(angle))

Haven't done anything this close to high school trigonometry in quite a while, so I might have made a little error somewhere, please be mindful of this 😊

 

Have a nice day!

As an alternative, draw a line from the point to the centerpoint, then use a Snipper to snip to a point on the line using the _z value.


joepk
Influencer
Forum|alt.badge.img+20
  • Influencer
  • February 26, 2024
joepk wrote:

I also managed to complete my workflow. I calculated the new coordinates of each vertex using these formulas:

x_moved = x + z * cos(degToRad(angle))
y_moved = y + z * sin(degToRad(angle))

Haven't done anything this close to high school trigonometry in quite a while, so I might have made a little error somewhere, please be mindful of this 😊

 

Have a nice day!

I think I have missed something, This workspace will perform an inward buffer with positive Z-values and an outward buffer with negative Z-values. I think you have to add a -1 to the formulas somewhere: 


x_moved = x + (-1 * z * cos(degToRad(angle)))
y_moved = y + (-1 * z * sin(degToRad(angle)))


raabster
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • February 26, 2024
nielsgerrits wrote:

The shapes you attached are 2D, so it is missing the 3rd coordinate you wanted to use to shift the points :)

 

I think @joepk his idea is better than mine.

I’m sorry for the error. zipped the wrong files… :(


raabster
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • February 26, 2024

Thank you both for your effort and help! Much appreciated!


geomancer
Evangelist
Forum|alt.badge.img+47
  • Evangelist
  • February 26, 2024

Nice to see these different approaches. I came up with yet another solution, that does not use the centerpoint of the polygon. Instead it bisects the inner angles of the original polygon (and it also works when the buffer distance is 0).

 


raabster
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • February 27, 2024

Nice! Thank you for your contribution 😀


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