I need to create an evenly distributed series of points within a series of oddly shapped polygons (formerly squares, but now squares with donut holes).

The way I have solved this problem so far is to create a fishnet of the polygon and then use the centroid of each unit that the fishnet creates.

However, the problem has become more complex and I now have more complex polygons. The centroids of the fishnet units are no longer good enough.

I was trying to convert the polygons to a raster and then use the Split tool for rasters, and create an output with a specified number of equal area units, but that won't work, as my input vector data doesn't have the necessary vaues for that raster process to run properly.

I am working with Arc 9.3 (but also have access to several other software packages)

  • 3
    "Evenly distributed" can mean several things, including equally spaced on a predefined grid, evenly spaced on a grid with random origin (and maybe random orientation), one randomly located point within each grid cell, uniformly random (needing no grid), and even random with a tendency to avoid one another. Could you be more specific about which one(s) you need? – whuber Apr 12 '11 at 21:50
  • Similar to this question? gis.stackexchange.com/questions/4828/… – Kirk Kuykendall Apr 12 '11 at 21:56
  • @whuber: Well... honestly, I'm not sure. Ideally the points would be spread out in such a way that the distance between the points was equalized as much as possible. They don't have to be in a perfect grid.Would that be uniformly random? – Kapjaki Apr 14 '11 at 4:48
  • These are subtle things, but no, equalizing the distances destroys much of the randomness. It guarantees that knowledge of one location makes knowledge of nearby locations much more predictable; in particular, the immediate (small) neighborhood of any point will be devoid of other points. That's not uniform at all! A good place to start when thinking about such things is to ponder how the points will be used. If they're for designing things, like planting trees, far apart is great. If you're going to do any statistical analysis with them, though, then watch out! – whuber Apr 14 '11 at 4:54
  • @Whuber: indeed, the intricacies you speak of are new to me. The purpose of this is to show potential locations for oil wells within a certain area. Randomness is not required, only that distance between points is maximized and distributed at least somewhat evenly throughout the bounding polygon. – Kapjaki Apr 15 '11 at 4:15

In QGIS if you install the fTools package, there is an option to generate 'Regular Points' (Tools -> Research Tools -> Regular Points)

enter image description here

| improve this answer | |
  • This will produce a grid of points, presumably? And is not constrained to lie within a polygon or set of polygons? (That's not a criticism: one can later remove all points lying outside a polygon.) – whuber Apr 13 '11 at 1:33
  • 2
    @whuber: The points will all lie within the polygon specified by "Input Boundary Layer" – underdark Apr 13 '11 at 7:48

You can do it in PostGIS with a query something like this:

SELECT grid.the_geom FROM 
(select st_setsrid(st_point(x, y), polygon_srid) AS the_geom from 
(select generate_series(minX, maxX, grid_size) AS x) AS a,
(select generate_series(minY, maxY, grid_size) AS y) AS b) AS grid,
WHERE ST_Within(grid.the_geom, polygon_table.the_geom);

You can try it out at postgisonline with this example:

SELECT grid.the_geom FROM 
(select st_setsrid(st_point(x, y), 3021) AS the_geom from 
(select generate_series(130000, 142000, 500) AS x) AS a,
(select generate_series(260000, 270000, 500) AS y) AS b) AS grid,
WHERE ST_Within(grid.the_geom, lakes.the_geom);

Put the query above in the textarea at the top and press Map1-button. You can also choose "lakes" from the background dropdown to see the polygon that is used to fill with points.


| improve this answer | |
  • Nicklas's post seems to be on the right track. Is there a way to specify how many points you want distributed in the lake thoguh? I've been looking for a method like this for a while. Thanks, Ray – user2670 Apr 13 '11 at 19:02
  • Is there someway to create 'blocks' from the polygon based on dividing the total area up equally? I.e. If 9 points are desired, divide the polygon into 9 'blocks' of equal area, and then get the centroids from those? – Kapjaki Apr 15 '11 at 4:19
  • Since the polygon can have any strange shape I guess that it would need some trial and error algorithm to achieve that. – Nicklas Avén Apr 15 '11 at 12:40
  • This seems to work well. Unfortunately I don't understand exactly how I can use it. How do I get my own data into the scenario? – Kapjaki Jun 14 '11 at 20:30
  • @Kapjaki, load your polygons into a postgis table and in my first example change "olygon_table" to whatever is the name of your polygons table. lso change in generate_series to match the extent of your polygons and change from 500 to whatever grid size you want. the query can be rewritten to find the extent directly. but not from my phone in a car :) – Nicklas Avén Jun 15 '11 at 7:26

You can use Lloyds algorithm:


| improve this answer | |

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.