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
U can use a vertextcreator set to a location (for instance x=0,y=0)
a cloner and a affiner.
replace creator in my picture by a vertexcreator.
I am using FME 2013. It has not vertexcreator tool. It's only creator tool.
Are they the same?
My input is polygon. I need create straitified random point for ldlr field. I want each filed has 10 random point.
I tried you asked, but I don't understand about processing . Could you explain for me? Thank you
My processing:
Do you mean creating random 10 points within each polygon?
I'm not sure how the ldlr field will be related to the required points.
Could you please draw a picture illustrating the expected output?
Takashi
Stratified Random Sampling is a statistical sampling strategy.
This site explains it for free:
https://explorable.com/probability-sampling
Greets
But I cannot understand why/how the method can be applied to create random points in this case. In my understanding, that is a sampling method for statistic survey. I'm not sure what is the stratification for creating random points based on a polygon...
The files could be considered as strata for the sampling.
So all Hoa needs is a disproportional sampling of the polygons in the files.
In this case it appears to be 10 for each polygon file. Not 10 per polygon.
So i suggested either using the ldlr range to pick from, or just the number of objects.
I assumed she is talking about files (with geometrytype polygon).
A dynamic reader of sorts is required to proces all files of course.
But i do not know what "ldlr" is. So it might as wel be that the Ldlr attribute is a list or string of values, who knows? Well, Hoa does ;)
But to be sure, we would need some sample data i guess...;)
I also don't know which is surname Hoa or Le?
I'm glad because i get support to you. in my queson, maybe my english skill is not good so you cant understand. now, i will give an example to more understanding.
For example: I have a forest status (polygon) and it has 3 attribute such as rich forest, poor forest, barren land. now, i want to create a pointl file that have 10 random point rich f?rest, 10 point poor forest and 10 points barren land (attribute of point file get from forest status).
you can call me Hoa. hi
Is it correct?
If yes, the following is a possible way. Assuming that the polygon features have an attribute named "status" which stores the forest status.
1) Compute a random number (e.g. "_rand") with the ExpressionEvaluator for every forest polygon. @rand function can be used.
2) Sort the features by "_rand" (Sorter).
3) Select first 10 features for each status with the Sampler.
Group By: status
Sampling Type: First N Features
Sampling Amount: 10
Then, where should the representative points be located?
If the points should be inside of sampled forest polygons, consider using the InsidePointReplacer transformer.
Thank you for your suport. I think that's a method. BUT I see in case, if I have 3 polygons rich forest, I use sampler tool it only create 3 polygons sample. But actualy, I need 10 points (It means 10 polygon rich forest).
When I used Quantum Gis to do that. Firstly, I split all polygon based on status. Then, I created random point for each status (For example: 15points). And I will assign attribute for them.
Finally, I merged all points file to one file which has information one point.
But in FME, how solution I can do that?
I draw a picture:
Sorry, I cannot understand the rule that should be applied to create the points.
Yes. In my image, there are two status forest (multiple polygon).
In other GIS software (Arcgis, Qgis...), they have a tool to create random point for polygon.
It means if you want to create 10 points for polygon, they will product a point file which has 10 points.
In FME, I can't do that :(((((
I tried as you talk. But I only do step cloner. Because I dont understand next step Cloner (pick (10) randomly: @round(@rand*@Value(_count)) or @round(@rand*@Value(_max)) ) how do it. Could you tell me how I used function to do that?
When I finish cloner function, I get result in picture. It has table which I want (It means one status has 10 points. But it has not geometry??? And it is not point???
Could you tell me how can I do? Thank you
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.
I made a workspace to pick the polygons.
At the end u can atach a Insidepointreplacer.
This does the sampling and will always return 10 unique choices per stratum, if the stratum has more thne samplingsize objects.
It is a bit compex(ish) as it uses variablesetter- and retriever. These are to ensure selection of (in your case 10) unique samples from each stratum.
attach your data and set the Stratum_Attribute=@Value(ldlr ())
The output you can now use to create random points.
Do i understand correctly if i say each polygon is one object in the file?
Then u might as wel use a insidepointreplacer to create the points.
Or does your file contain overlappingforestareas? (then maybe a AreaOnArea would be an idea)
I do that to step 6. In the step 7: Cloner; Number of Copies:
@int($(NUM_POINTS)*$(NUM_POINTS)*@double(@Value(_area2))/@Value(_area1)+0.5)
NUM_POINTS means variable? I tried copy it to Number of Copies, the button OK is invisible.
Did you define a user parameter named "NUM_POINTS"?
Did you specify attribute names "_area1" and "_area2" in the AreaCalculators?
Did you connect the Cloner to the data flow including the AreaCaluclators?
As I mentioned in the previous post, the steps are assuming that a user parameter named "NUM_POINTS" has been defined in the workspace. I intended that the parameter indicates the sampling amount. e.g. 10 or 15.
Working with User Parameters (http://docs.safe.com/fme/html/FME_Workbench/Default.htm#published_private_parameters.htm)
I tried to do that. It's excellent...So great . Thank you very much.
I will try Gio's approach :)
Thank you
I checked and I saw some points is over polygon. I think , maybe replace spatialFilter by clip?
How do u feel?