## Tuesday, May 31, 2011

### PostGIS function for a random point inside a polygon -- page on PostGIS wiki

I have created a page on PostGIS wiki with the description of the random point functions: http://trac.osgeo.org/postgis/wiki/UserWikiRandomPoint

## Monday, May 23, 2011

### PostGIS function for a random point inside a polygon -- REVISED

This is a revised random-point-in-polygon function first discussed in my earlier post. It turns out that in some weird cases (multipolygons consisting of a number of small and disperse polygons) the function takes too many iterations to complete. Below is a code for another function called RandomPointMulti that addresses this problem. RandomPointMulti breaks a multipolygon into polygons, randomly chooses a polygon with the probability proportional to the area of the polygon, and then calls original RandomPoint on that polygons. RandomPoint was also modified: some typos have been fixed, exception is thrown if the max number of iterations has been exceeded, and and max number of iterations can be specified as an argument.

Subscribe to:
Posts (Atom)