[R-sig-Geo] Creating random (but believable) geographies

Roger Bivand Roger.Bivand at nhh.no
Mon Dec 28 13:57:26 CET 2009

On Mon, 28 Dec 2009, Barry Rowlingson wrote:

> On Mon, Dec 28, 2009 at 11:20 AM, Jim Lemon <jim at bitwrit.com.au> wrote:
>> Hi Barry,
>> The first thing I thought of was to specify nodes (intersections of borders
>> = vertices of polygons) and then wiggle the lines between the nodes using
>> something like this:
>> wigglyLine<-function(xstart,ystart,xend,yend,nseg=20,mult=1) {
>>  xvec<-seq(xstart,xend,length.out=nseg+1)
>>  yvec<-seq(ystart,yend,length.out=nseg+1)
>>  xvec[2:nseg]<-xvec[2:nseg]+(runif(nseg-1)-0.5)*mult
>>  yvec[2:nseg]<-yvec[2:nseg]+(runif(nseg-1)-0.5)*mult
>>  return(list(x=xvec,y=yvec))
>> }
>> Obviously there are a lot of things that you could fiddle with here,
>> including the easiest way to specify the vertices and then turn the wiggled
>> edges into polygons. It does solve the problem of having the polygons fit
>> together, though.
> My preferred wiggle algorithm is a fractal - for a line from points A
> to B, choose a point C "between" A and B and create two lines AC and
> CB. Repeat (recurse) for lines AC and CB up to a number of recursions.
> Three or four should be enough.
> If you start with Voronoi polygon edges then you only have to check
> that point C is inside either of the polygons on either side of AB to
> keep the topology.

Couldn't you rather start from a hexagon grid, given the typical number of 
neighbours of "real" entities? Snipping in some straight lines (parallels) 
and some rivers might also make sense. Are there suitable collections of 
entities in gaming etc.? Or generate a DEM and take drainage basins?


> There's some more choices here - you could either fully fractalise
> one segment at a time, or do all the first divisions over the space,
> then the subdivisions and so on. Also there's the definition of
> "between", which strictly doesn't even have to be between A and B
> (it's just more likely to be in one of the polygons if it is).
> May I also suggest that if anyone does generate some fake countries
> that we place them in the middle of an ocean...
> Barry
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no

More information about the R-sig-Geo mailing list