Skip to main content
Solved

Create polygon from point or centroid

  • September 26, 2017
  • 6 replies
  • 267 views

I have a series of point, from each point, I would like to create a specific rectangle with height and width specified. The point provided are treated as centroid of the polygon (rectangle).

Or, even better, the polygon would be in a specified angle, but this is not required...

Is there a workflow for this process? Thanks!

Best answer by erik_jan

Or you could create a rectangle for each point using the Bufferer transformer (buffer type square).

That would automatically have the point as center point.

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

6 replies

xiaomengatsafe
Safer
Forum|alt.badge.img+3

Hi @gisluo, Thank you for posting this question.

Here is a idea to try (might not be the most elegant method):

 

1. Since the rectangle will be of the same shape and size, they are only different in their location (and angle), we can create a rectangle using a Creator transformer. Create this polygon, so it's center point is at 0,0.

2. Parallel to the Creator, read in the points, and extract the x y coordinates

3. Use a FeatureMerger to merge the points (Supplier) with the created polygon (Requester). Since we want to merge every point with the polygon, you can simply set the Join On values for Requestor and Supplier to both be 1. This will do a blind join of the two data stream. Also, Set Feature Merge Type to Attributes Only.

4. Now that the polygons has the x y coordinates of the points, we can use an Offsetter to move each polygon to the location of the points using the extracted X Y coordinate attribute. And if the points had an attribute with the angle, you can also use an Rotator to rotate it by the angle attribute.

Hope this helps.

Xiaomeng


xiaomengatsafe
Safer
Forum|alt.badge.img+3
xiaomengatsafe wrote:

Hi @gisluo, Thank you for posting this question.

Here is a idea to try (might not be the most elegant method):

 

1. Since the rectangle will be of the same shape and size, they are only different in their location (and angle), we can create a rectangle using a Creator transformer. Create this polygon, so it's center point is at 0,0.

2. Parallel to the Creator, read in the points, and extract the x y coordinates

3. Use a FeatureMerger to merge the points (Supplier) with the created polygon (Requester). Since we want to merge every point with the polygon, you can simply set the Join On values for Requestor and Supplier to both be 1. This will do a blind join of the two data stream. Also, Set Feature Merge Type to Attributes Only.

4. Now that the polygons has the x y coordinates of the points, we can use an Offsetter to move each polygon to the location of the points using the extracted X Y coordinate attribute. And if the points had an attribute with the angle, you can also use an Rotator to rotate it by the angle attribute.

Hope this helps.

Xiaomeng

Also, when creating the polygon in the Creator, consider set the coordinate system to be the same as the point coordinate system. Or, you can set the coordinate system, after merging, using a CoordinateSystemSetter.

 

 


erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • Best Answer
  • September 26, 2017

Or you could create a rectangle for each point using the Bufferer transformer (buffer type square).

That would automatically have the point as center point.


  • September 26, 2017

I would add a point through the VertexCreator with width and height (for x and y respectively), then use a BoundingBoxReplacer and finally 'Offsetter' it by -width/2 and -height/2.


xiaomengatsafe
Safer
Forum|alt.badge.img+3
erik_jan wrote:

Or you could create a rectangle for each point using the Bufferer transformer (buffer type square).

That would automatically have the point as center point.

Oh, yeah, that's much simpler, Thanks, @erik_jan!

 

If the polygons are not squares, you can buffer by 1, and then use a Scaler to scale x y using the desired scale factor to create the rectangle that you need. (Note the Scale Origin should be Center Point)

 


takashi
Influencer
  • September 27, 2017

I would use the CoordinateExtractor, 2DBoxReplacer, and Rotator. Assume the point has height, width, and rotation angle as its attributes, this screenshot illustrates my intention.

 


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