I have a polygon file which has ID code. I want to create random point for each ID code.
For example: each ID create 10 random points.
Could you tell me how can I do ? Thank you
I have a polygon file which has ID code. I want to create random point for each ID code.
For example: each ID create 10 random points.
Could you tell me how can I do ? Thank you
Best answer by takashi
Create aggregate polygons grouped by the forest status attribute (e.g. "status").
Create random points of enough large number within the bounding box for each aggregate feature.
Select the points which are inside of the original polygons based on their spatial relationships.
Select randomly points of required number (e.g. 10 or 15) from the points.
The point is how to compute the enough large number. My approach is to compute it based on area ratio between the original polygons and its bounding box.
Assuming that the required number is given as a user parameter named "NUM_POINTS":
1. Create random points within bounding box
1) Aggregator; Group By: status
2) AreaCaluculator; Area Attribute: _area1
3) BoundingBoxReplacer
4) AreaCalculator; Area Attribute: _area2
5) BoundsExtractor
6) 2DPointReplacer; XValue: _xmin, YValue: _ymin
7) Cloner; Number of Copies:
@int($(NUM_POINTS)*$(NUM_POINTS)*@double(@Value(_area2))/@Value(_area1)+0.5)
8) Offsetter (randomize location of every point)
X Offset: @rand()*(@Value(_xmax)-@Value(_xmin))
Y Offset: @rand()*(@Value(_ymax)-@Value(_ymin))
2. Filter the points
Then, filter the points by the original polygons using SpatialFilter (Group By: status).
3. Select randomly points of required number
Finally, select randomly points of required number from the filtered points.
1) Add a random number to every point (ExpressionEvaluator; use @rand function).
2) Sort the points by the random number.
3) Select first NUM_POINTS points for each status by Sampler.
Group By: status
Sampling Type: First N Features
Sampling Amount: $(NUM_POINTS)
Hope this works as expected.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.