Question

Create Only 1 Random Point within Polygons

  • 13 September 2019
  • 3 replies
  • 17 views

Badge

Hello,

I would like to create random points within polygons based on a pre-defined stratification and number of plots field. For example, within the LBS-1-Old strata, 53 random points are needed; however, only one point per polygon is required. Additionally, all points need to be separated by at least 200m. Ideally, the points would also be 200m from the edge of the polygon as well. The ArcGIS 'Create Random Points' tool can create these points based on the NUM_PLOTS field and separate them by at least 200m; however, multiple plots per polygon are possible and ensuring points are farther than 200m from the edges is not. I was wondering if a FME workflow could address all requirements. Thanks.


3 replies

Userlevel 3
Badge +17

Hi @aviveiro

Would randomly sampled points on a grid be random enough for your purposes?

If yes, you can try coercing the polygons to point clouds using the PointCloudCombiner and setting the point interval parameter as the minimum distance between points. This creates a point cloud (grid) and should ensure potential points will not fall within a minimum distance of each other.

A PointCloudPropertyExtractor and a Python script can be used to determine which points will be randomly sampled. The Python script selects a number of points based on the number of points to create attribute randomly and creates a list for each area. Use a FeatureJoiner/FeatureMerger find the sampled points by joining on the name of the area and point id.

To ensure no points are created within a certain distance of the boundary of the edge of the polygon, try performing a negative buffer using the Bufferer before the polygons are coerced into point clouds.

I have attached a template workspace demonstrating this approach. generaterandompointsinpolygons.fmwt

Edit: I may have misread your post on the first read. If you only need one point per polygon, perhaps you can look at the RandomPointGenerator on the FME Hub?

Badge

Hi @aviveiro

Would randomly sampled points on a grid be random enough for your purposes?

If yes, you can try coercing the polygons to point clouds using the PointCloudCombiner and setting the point interval parameter as the minimum distance between points. This creates a point cloud (grid) and should ensure potential points will not fall within a minimum distance of each other.

A PointCloudPropertyExtractor and a Python script can be used to determine which points will be randomly sampled. The Python script selects a number of points based on the number of points to create attribute randomly and creates a list for each area. Use a FeatureJoiner/FeatureMerger find the sampled points by joining on the name of the area and point id.

To ensure no points are created within a certain distance of the boundary of the edge of the polygon, try performing a negative buffer using the Bufferer before the polygons are coerced into point clouds.

I have attached a template workspace demonstrating this approach. generaterandompointsinpolygons.fmwt

Edit: I may have misread your post on the first read. If you only need one point per polygon, perhaps you can look at the RandomPointGenerator on the FME Hub?

Hi @debbiatsafe

Thanks for the reply. I'll review the workspace provided.

To clarify, I have a feature class of forest inventory polygons that I need to create random points within using a pre-defined stratification. So the 53 random points referenced above would need to be in 53 separate polygons that have a LBS-1-Old stratification. Similarly, 30 points need to be created within 30 different forest inventory polygons with the SFWD-3-Mature stratification and so on. Only one random point is permitted per polygon.

In reviewing the RandomPointGenerator, a fixed number of points is entered; however, I need to generate different numbers of random points per stratification as specified in the num_plots field.

Userlevel 5
Badge +25

Hi @debbiatsafe

Thanks for the reply. I'll review the workspace provided.

To clarify, I have a feature class of forest inventory polygons that I need to create random points within using a pre-defined stratification. So the 53 random points referenced above would need to be in 53 separate polygons that have a LBS-1-Old stratification. Similarly, 30 points need to be created within 30 different forest inventory polygons with the SFWD-3-Mature stratification and so on. Only one random point is permitted per polygon.

In reviewing the RandomPointGenerator, a fixed number of points is entered; however, I need to generate different numbers of random points per stratification as specified in the num_plots field.

The separation will be a tricky story, based on your geometry that might not even be possible to achieve. A grid approach might be a better idea then, generate a 2D Grid with the 2DGridAccumulator and then use a PointOnAreaOverlayer. A NeighborFinder, grouping the points and polygons will give you the distance of each point to the edge of the polygon it's contained by and that should allow you to find out which is the furthest from the edge.

Reply