I am trying to generate around 117 random points over patchy forested landscape. As my forested landscape contaisn many polygons (28.000), and I would like to generate specific number of random points, I first dissolve my polygon, to create multipart polygon, as speciefied in ArcGIS help.

Example of my very patchy landscape, polygons are forests, white parts are not forested:

enter image description here

So, to generate random points, I am using as constraints a multipart polygon and minimal distance points.

However, no matter what required number of points in number_of_points_or_field I specify (should by 117 if I quess correctly), I always get back number around 75.

I understand that if my points cannot fit the polygon under minimal distance restriction, there is less of them.

But, I got back the same number of 75 points, even if I set lower number, i.e. 10: number_of_points_or_field = 10.

Why does this happen?

Here is my code:

# Read input forest data
inForest = os.path.join(inWD, "patchyForest")

# Process: Dissolve feature to create single multipart polygon 
outForestDiss = os.path.join(outDB, "forest_diss")
arcpy.Dissolve_management(in_features = inForest ,
                          out_feature_class = outForestDiss,
                          dissolve_field = "",
                          statistics_fields = "",
                          multi_part = "MULTI_PART",
                          unsplit_lines = "")

# Process: generate random points within the forested area
outPtsName = "randomPoints"
numberPoints = 117  # tried with 10, 75, 117 and I always get back number 75
arcpy.CreateRandomPoints_management(out_path = outDB,
                                    out_name = outPtsName,
                                    constraining_feature_class = outForestDiss,
                                    # constraining_extent = "", # skip this one out
                                    number_of_points_or_field = numberPoints,   
                                    minimum_allowed_distance = distanceBuff * 2,
                                    create_multipoint_output = "POINT") 
  • Try to leave out the constrained extent, if i use the tool this parameter has a specific value, may be a default? – Andreas Müller Oct 9 '19 at 14:19
  • @AndreasMuller, thank you for suggestion, I have commented the constraining_extent out, but I still get back the same result.. 75.. I think the extent is deprecated, if I use as a constraint feature class. Do you maybe have another suggestions? – maycca Oct 9 '19 at 14:54
  • Try exploding your multi-part polygon into single part then run the tool? – Hornbydd Oct 9 '19 at 17:57
  • I have odd results when the Spatial Reference for my constraint featureclass and Data Frame do not agree. The tool works with multipart polygons. When the SR's agree, the number of output Points match the number of points specified per singlepart or multipart polygon. Testing with ArcGIS 10.5 – klewis Oct 9 '19 at 18:25
  • Stacked polygons seem to confuse the Tool, createrandompoints. – klewis Oct 9 '19 at 18:26

I have figure out that the Dissolve tools is causing issues with improper number of generated points. Dissolve tool did not dissolve the whole shapefile as it is supposed too, but instead instead create several linear features. Here is example of the dissolved file, still having several features, but are obviously erroneous due to linear shape:

enter image description here

Apparently, the use of the Dissolve tool within the chain of tools using arcpy usually causes troubles as can be found here. Neither the adding extra Field, populating it with a string, and applied Dissolve based on this Field helped.

The only workaround I have found was to manually dissolve the polygon to generate exactly 1 multipart polygon, and than gerenate the correct number of random points.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.