[R-sig-Geo] Natural Breaks Classification

David Bitner osgis.lists at gmail.com
Fri Feb 24 20:08:50 CET 2006


I am trying to create some type of a Natural Breaks Classification in
PL/R  to classify data that I have in a PostgreSQL/PostGIS database. 
All that I really need so that I can pass information on to Mapserver
to display this data is the class break values (ie an array [3,5,7,9]
would mean show values 1-3 in blue, 4-5 in red, etc.).  I am
completely new to R, but have a fair bit of experience with the other
PL's in PostgreSQL, so the PL part shouldn't be too hard to figure
out.

I am thinking that kmeans should give me something close to what I
want.  My problem is that I am not quite sure to massage the output to
get my class breaks or what format to input the data.

For arguments, kmeans takes a matrix, number of classes, and a max
number of iterations --
last two are easy, but how do I convert (do I need to convert) an
array into a matrix (is matrix just R speak for an array?)  I will be
starting with a one dimension array ie ([1,4,1,1,1,6,4,9,9]).

The next issue is spitting the data out.  The docs tell me that I get
the centers of the clusters where what I really want are the
boundaries of the clusters, how could I get at the "break points" that
I am after?

Any help is appreciated,
David




More information about the R-sig-Geo mailing list